1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # vaster
//!
//! Raster grid logic, without any pesky data.
//!
//! Raster grids are defined by **dimension** (ncol, nrow) and **extent**
//! (xmin, xmax, ymin, ymax). Everything else — resolution, cell centres,
//! geotransforms, cell indexing — derives from those six numbers.
//!
//! This crate provides that derivation with **zero dependencies**.
//!
//! ## Conventions
//!
//! - **Extent** is `[xmin, xmax, ymin, ymax]` — same as the R `vaster` package
//! - **Dimension** is `[ncol, nrow]`
//! - **Cell indices** are 0-based (the R package uses 1-based)
//! - **Geotransform** follows GDAL convention:
//! `[origin_x, pixel_width, row_rotation, origin_y, col_rotation, pixel_height]`
//! - Cell (0, 0) is the **top-left** pixel, traversing right then down
//!
//! ## GDAL geotransform
//!
//! The 6-element geotransform maps pixel coordinates to geographic coordinates:
//!
//! ```text
//! x_geo = gt[0] + pixel * gt[1] + line * gt[2]
//! y_geo = gt[3] + pixel * gt[4] + line * gt[5]
//! ```
//!
//! For north-up images (no rotation): `gt[2] == 0`, `gt[4] == 0`, `gt[5] < 0`.
//!
//! Reference: <https://gdal.org/tutorials/geotransforms_tut.html>
//!
//! ## Quick start
//!
//! ```
//! use vaster::*;
//!
//! let extent = [0.0, 360.0, -90.0, 90.0];
//! let dim = [360, 180];
//!
//! // Build a geotransform
//! let gt = extent_dim_to_gt(&extent, &dim);
//! assert_eq!(gt[1], 1.0); // 1 degree per pixel
//!
//! // Cell centre of top-left pixel
//! let (x, y) = xy_from_cell(&dim, &extent, 0);
//! assert!((x - 0.5).abs() < 1e-10);
//! assert!((y - 89.5).abs() < 1e-10);
//!
//! // Which cell contains a point?
//! let cell = cell_from_xy(&dim, &extent, 10.3, 45.7);
//! assert_eq!(cell, Some(10 + 44 * 360));
//! ```
//!
//! ## Relationship to the R package
//!
//! This crate is the Rust equivalent of [hypertidy/vaster](https://github.com/hypertidy/vaster),
//! an R package for raster grid logic. The API follows the same conventions
//! with one difference: cell indices are **0-based** in Rust (1-based in R).
pub use *;
pub use *;
pub use *;
pub use *;
/// A GDAL-style affine geotransform.
///
/// `[origin_x, pixel_width, row_rotation, origin_y, col_rotation, pixel_height]`
///
/// For north-up images: index 2 and 4 are zero, index 5 is negative.
pub type GeoTransform = ;
/// Raster extent: `[xmin, xmax, ymin, ymax]`.
pub type Extent = ;
/// Raster dimensions: `[ncol, nrow]`.
pub type Dimension = ;