pub struct GeoTransform {
pub origin_x: f64,
pub pixel_width: f64,
pub row_rotation: f64,
pub origin_y: f64,
pub col_rotation: f64,
pub pixel_height: f64,
}Expand description
An affine transformation matrix for converting between pixel and world coordinates
The transformation follows the GDAL convention:
x_geo = c0 + pixel_x * c1 + pixel_y * c2
y_geo = c3 + pixel_x * c4 + pixel_y * c5For a north-up image:
c1(pixel width) is positivec5(pixel height) is negative (Y increases downward in pixel space)c2andc4(rotation terms) are zero
Fields§
§origin_x: f64X coordinate of the upper-left corner of the upper-left pixel (origin X)
pixel_width: f64W-E pixel resolution (pixel width)
row_rotation: f64Row rotation (typically zero for north-up images)
origin_y: f64Y coordinate of the upper-left corner of the upper-left pixel (origin Y)
col_rotation: f64Column rotation (typically zero for north-up images)
pixel_height: f64N-S pixel resolution (pixel height, typically negative)
Implementations§
Source§impl GeoTransform
impl GeoTransform
Sourcepub const fn new(
origin_x: f64,
pixel_width: f64,
row_rotation: f64,
origin_y: f64,
col_rotation: f64,
pixel_height: f64,
) -> GeoTransform
pub const fn new( origin_x: f64, pixel_width: f64, row_rotation: f64, origin_y: f64, col_rotation: f64, pixel_height: f64, ) -> GeoTransform
Creates a new GeoTransform from the six coefficients
§Arguments
origin_x- X coordinate of the upper-left cornerpixel_width- W-E pixel resolutionrow_rotation- Row rotation (0 for north-up)origin_y- Y coordinate of the upper-left cornercol_rotation- Column rotation (0 for north-up)pixel_height- N-S pixel resolution (negative for north-up)
Sourcepub const fn north_up(
origin_x: f64,
origin_y: f64,
pixel_width: f64,
pixel_height: f64,
) -> GeoTransform
pub const fn north_up( origin_x: f64, origin_y: f64, pixel_width: f64, pixel_height: f64, ) -> GeoTransform
Creates a north-up GeoTransform (no rotation)
§Arguments
origin_x- X coordinate of the upper-left cornerorigin_y- Y coordinate of the upper-left cornerpixel_width- Pixel width (positive)pixel_height- Pixel height (negative for north-up)
Sourcepub const fn from_gdal_array(coeffs: [f64; 6]) -> GeoTransform
pub const fn from_gdal_array(coeffs: [f64; 6]) -> GeoTransform
Creates a GeoTransform from the standard GDAL 6-element array
The array format is: [origin_x, pixel_width, row_rotation, origin_y, col_rotation, pixel_height]
Sourcepub const fn to_gdal_array(&self) -> [f64; 6]
pub const fn to_gdal_array(&self) -> [f64; 6]
Converts to the standard GDAL 6-element array
Sourcepub const fn identity() -> GeoTransform
pub const fn identity() -> GeoTransform
Creates an identity transform (pixel = world)
Sourcepub fn from_bounds(
bbox: &BoundingBox,
width: u64,
height: u64,
) -> Result<GeoTransform, OxiGdalError>
pub fn from_bounds( bbox: &BoundingBox, width: u64, height: u64, ) -> Result<GeoTransform, OxiGdalError>
Sourcepub fn world_to_pixel(
&self,
world_x: f64,
world_y: f64,
) -> Result<(f64, f64), OxiGdalError>
pub fn world_to_pixel( &self, world_x: f64, world_y: f64, ) -> Result<(f64, f64), OxiGdalError>
Sourcepub fn pixel_center(&self, pixel_x: u64, pixel_y: u64) -> (f64, f64)
pub fn pixel_center(&self, pixel_x: u64, pixel_y: u64) -> (f64, f64)
Returns the center of a pixel in world coordinates
Sourcepub fn compute_bounds(&self, width: u64, height: u64) -> BoundingBox
pub fn compute_bounds(&self, width: u64, height: u64) -> BoundingBox
Sourcepub fn is_north_up(&self) -> bool
pub fn is_north_up(&self) -> bool
Returns true if this is a north-up transform (no rotation)
Sourcepub fn has_rotation(&self) -> bool
pub fn has_rotation(&self) -> bool
Returns true if the transform has rotation
Sourcepub fn resolution(&self) -> (f64, f64)
pub fn resolution(&self) -> (f64, f64)
Returns the absolute pixel resolution (ignoring sign)
Sourcepub fn rotation_radians(&self) -> f64
pub fn rotation_radians(&self) -> f64
Returns the rotation angle in radians (assuming uniform scaling)
The rotation is calculated from the affine transformation matrix.
For a standard rotation, this extracts the angle from the col_rotation
and pixel_width terms.
Sourcepub fn rotation_degrees(&self) -> f64
pub fn rotation_degrees(&self) -> f64
Returns the rotation angle in degrees
Sourcepub fn inverse(&self) -> Result<GeoTransform, OxiGdalError>
pub fn inverse(&self) -> Result<GeoTransform, OxiGdalError>
Sourcepub fn compose(&self, other: &GeoTransform) -> GeoTransform
pub fn compose(&self, other: &GeoTransform) -> GeoTransform
Composes two transforms: self followed by other
The result transforms from pixel space through self to world space, then from world space through other.
Sourcepub const fn scale(&self, scale_x: f64, scale_y: f64) -> GeoTransform
pub const fn scale(&self, scale_x: f64, scale_y: f64) -> GeoTransform
Scales the transform by the given factors
Sourcepub const fn translate(&self, offset_x: f64, offset_y: f64) -> GeoTransform
pub const fn translate(&self, offset_x: f64, offset_y: f64) -> GeoTransform
Translates the transform by the given offset
Trait Implementations§
Source§impl Clone for GeoTransform
impl Clone for GeoTransform
Source§fn clone(&self) -> GeoTransform
fn clone(&self) -> GeoTransform
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more