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(());
}
let tif = GeoTiff::read(p)?;
println!(
"Original loaded. Size (Bands, Height, Width): {:?}",
tif.data.dim()
);
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
);
let output_path = Path::new("./data/simple_crop.tif");
cropped.write(output_path)?;
println!("Saved cropped result to: {:?}", output_path);
Ok(())
}