| Crates.io | hydro-analysis |
| lib.rs | hydro-analysis |
| version | 0.1.0 |
| created_at | 2025-03-17 23:04:59.967677+00 |
| updated_at | 2025-04-08 00:21:28.916365+00 |
| description | Hydrolog anaylsis tools for manipulating DEMs |
| homepage | https://github.com/mrmattwilkins/hydro-analysis |
| repository | https://github.com/mrmattwilkins/hydro-analysis |
| max_upload_size | |
| id | 1595972 |
| size | 41,234 |
hydro-analysis provides functions for Hydrology DEM manipulation. There are
a couple generic functions for reading/writing raster files of any common
primative type (which surprizingly I couldn't find anywhere else, unless you
use GDAL which I am trying to avoid). Also there are a couple functions based
on whitebox. Whitebox is a
command line tool, this provides functionality via functions so can be called
from your code.
let ifn = PathBuf::from("input.tif");
let (d8, nd, crs, geo, gdir, proj) = rasterfile_to_array::<u8>(&ifn)?;
/* do something with d8, or make a new array2 */
let ofn = PathBuf::from("output.tif");
if let Err(e) = array_to_rasterfile::<u8>(&d8, nd, &geo, &gdir, &proj, &ofn) {
eprintln!("Error occured while writing {}: {:?}", ofn.display(), e);
}
use ndarray::Array2;
use hydro_analysis::{fill_depressions, d8_pointer};
let mut dem = Array2::from_shape_vec(
(3, 3),
vec![
10.0, 12.0, 10.0,
12.0, 9.0, 12.0,
10.0, 12.0, 10.0,
],
).expect("Failed to create DEM");
fill_depressions(&mut dem, -3.0, 8.0, 8.0, true);
let (d8, d8_nd) = d8_pointer(&dem, -1.0, 8.0, 8.0);