rstiff 0.2.0

A Rust library for high-precision, type-preserving GeoTiff I/O powered by GDAL.
use rstiff::GeoTiff;
use std::error::Error;
use std::path::Path;

fn main() -> Result<(), Box<dyn Error>> {
    let p = Path::new("./data/Hawaiin_part.tif");
    if !p.exists() {
        println!("Please provide ./data/Hawaiin_part.tif");
        return Ok(());
    }

    // 1. Read
    let tif = GeoTiff::read(p)?;
    println!(
        "Original loaded. Size (Bands, Height, Width): {:?}",
        tif.data.dim()
    );

    // 2. Simple Crop (Row/Col)
    // Parameters: x_off (col), y_off (row), width, height
    // Example: Crop a 500x500 area starting from (1000, 1000)
    let x_off = 1000;
    let y_off = 1000;
    let width = 500;
    let height = 500;

    println!(
        "Cropping window: x={}, y={}, w={}, h={}",
        x_off, y_off, width, height
    );
    let cropped = tif.crop(x_off, y_off, width, height)?;
    println!(
        "Crop success. New Size: {:?}, GeoTransform: {:?}",
        cropped.data.dim(),
        cropped.geo_transform
    );

    // 3. Write
    let output_path = Path::new("./data/simple_crop.tif");
    cropped.write(output_path)?;
    println!("Saved cropped result to: {:?}", output_path);

    Ok(())
}