Type Definition gdal::GeoTransform

source ·
pub type GeoTransform = [c_double; 6];
Expand description

A six-element array storing the coefficients of an affine transform used in mapping coordinates between pixel/line (P, L) (raster) space, and (Xp,Yp) (projection/SpatialRef) space.

Interpretation

A GeoTransform’s components have the following meanings:

  • GeoTransform[0]: x-coordinate of the upper-left corner of the upper-left pixel.
  • GeoTransform[1]: W-E pixel resolution (pixel width).
  • GeoTransform[2]: row rotation (typically zero).
  • GeoTransform[3]: y-coordinate of the upper-left corner of the upper-left pixel.
  • GeoTransform[4]: column rotation (typically zero).
  • GeoTransform[5]: N-S pixel resolution (pixel height), negative value for a North-up image.

Note

Care with coefficient ordering is required when constructing an affine transform matrix from a GeoTransform. If a 3x3 transform matrix is defined as:

| a b c |
| d e f |
| 0 0 1 |

The corresponding GeoTransform ordering is:

[c, a, b, f, d, e]

Usage

  • apply: perform a (P,L) -> (Xp,Yp) transformation
  • invert: construct the inverse transformation coefficients for computing (Xp,Yp) -> (P,L) transformations

Example

use gdal::{Dataset, GeoTransformEx};
let ds = Dataset::open("fixtures/m_3607824_se_17_1_20160620_sub.tif")?;
let transform = ds.geo_transform()?;
let (p, l) = (0.0, 0.0);
let (x,y) = transform.apply(p, l);
println!("(x,y): ({x},{y})");
let inverse = transform.invert()?;
let (p, l) = inverse.apply(x, y);
println!("(p,l): ({p},{l})");

Output:

(x,y): (768269,4057292)
(p,l): (0,0)

See Also

Trait Implementations§

source§

impl GeoTransformEx for GeoTransform

source§

fn apply(&self, pixel: f64, line: f64) -> (f64, f64)

Apply GeoTransform to x/y coordinate. Read more
source§

fn invert(&self) -> Result<GeoTransform>