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 input = Path::new("./data/Hawaiin_part.tif");
    if !input.exists() {
        println!("Please provide ./data/Hawaiin_part.tif");
        return Ok(());
    }

    // 1. Read the file
    // The library automatically detects:
    // - Dimensions (3 bands, 5184x6016)
    // - Data Type (Byte)
    // - GeoTransform & Projection
    println!("Reading: {:?}", input);
    let mut tif = GeoTiff::read(input)?;
    println!(
        "Successfully read. Type: {:?}, NoData: {:?}",
        tif.original_type, tif.nodata
    );

    // 2. (Optional) Process Data
    // tif.data is an ndarray::Array3<f64>. You can modify it here.
    // Example: Add 100 to the first pixel of the first band
    if let Some(val) = tif.data.get_mut((0, 0, 0)) {
        println!("Old pixel value at (0,0,0): {}", val);
        *val += 50.0;
        println!("New pixel value at (0,0,0): {}", val);
    }

    // 3. Write it back
    // The library handles type conversion (f64 -> Byte) and NoData transparency automatically.
    let output = Path::new("./data/basic_io_output.tif");
    tif.write(output)?;
    println!("Written modified data to: {:?}", output);

    Ok(())
}