GDAL

Public Member Functions | Public Attributes | List of all members
GDALGeoTransform Class Reference

Class that encapsulates a geotransform matrix. More...

`#include <gdal_geotransform.h>`

## Public Member Functions
| GDALGeoTransform ()=default
| Default constructor for an identity geotransformation matrix.
| GDALGeoTransform (const double coeffs[6])
| Constructor from a array of 6 double.
| GDALGeoTransform (double xorigIn, double xscaleIn, double xrotIn, double yorigIn, double yrotIn, double yscaleIn)
| Constructor from 6 double values.
template<typename T >
double | operator[] (T idx) const
| Element accessor.
template<typename T >
double & | operator[] (T idx)
| Element accessor.
bool | operator== (const GDALGeoTransform &other) const
| Equality test operator.
bool | operator!= (const GDALGeoTransform &other) const
| Inequality test operator.
const double * | data () const
| Cast to const double*.
double * | data ()
| Cast to double*.
void | Apply (double dfPixel, double dfLine, double *pdfGeoX, double *pdfGeoY) const
| Apply GeoTransform to x/y coordinate.
bool | Apply (const OGREnvelope &env, GDALRasterWindow &window) const
| Apply a (inverse) geotransform to an OGREnvelope in georeferenced coordinates.
bool | Apply (const GDALRasterWindow &window, OGREnvelope &env) const
| Apply a geotransform to a GDALRasterWindow in pixel/line coordinates.
std::pair< double, double > | Apply (double dfPixel, double dfLine) const
| Apply GeoTransform to x/y coordinate.
bool | GetInverse (GDALGeoTransform &inverse) const
| Invert Geotransform.
void | Rescale (double dfXRatio, double dfYRatio)
| Rescale a geotransform by multiplying its scale and rotation terms by the provided ratios.
bool | IsAxisAligned () const
| Check whether the geotransform has a rotation component.

## Public Attributes
double | xorig = 0
| X value of the origin of the raster.
double | xscale = 1
| X scale factor.
double | xrot = 0
| X rotation factor.
double | yorig = 0
| Y value of the origin of the raster.
double | yrot = 0
| Y rotation factor.
double | yscale = 1
| Y scale factor.

## Detailed Description

Class that encapsulates a geotransform matrix.

It contains 6 coefficients expressing an affine transformation from (column, line) raster space to (X, Y) georeferenced space, such that

X = xorig + column * xscale + line * xrot;
Y = yorig + column * yrot + line * yscale;
GDALGeoTransform::xorig
double xorig
X value of the origin of the raster.
Definition gdal_geotransform.h:47
GDALGeoTransform::yrot
double yrot
Y rotation factor.
Definition gdal_geotransform.h:59
GDALGeoTransform::yorig
double yorig
Y value of the origin of the raster.
Definition gdal_geotransform.h:56
GDALGeoTransform::xscale
double xscale
X scale factor.
Definition gdal_geotransform.h:50
GDALGeoTransform::xrot
double xrot
X rotation factor.
Definition gdal_geotransform.h:53
GDALGeoTransform::yscale
double yscale
Y scale factor.
Definition gdal_geotransform.h:62

The default value is the identity transformation.

Since
  3.12

## Member Function Documentation

## ◆ Apply() [1/4]

bool GDALGeoTransform::Apply | ( | const GDALRasterWindow & | window,
|  | OGREnvelope & | env
| ) |  | const

Apply a geotransform to a GDALRasterWindow in pixel/line coordinates.

Parameters

  | window | A window in pixel/line coordinates
  [out] | env | An envelope in georeferenced coordinates

Returns
  true if the geotransform was successfully applied

## ◆ Apply() [2/4]

bool GDALGeoTransform::Apply | ( | const OGREnvelope & | env,
|  | GDALRasterWindow & | window
| ) |  | const

Apply a (inverse) geotransform to an OGREnvelope in georeferenced coordinates.

Parameters

  | env | An envelope in georeferenced coordinates
  [out] | window | A window in pixel/line coordinates

Returns
  true if the geotransform was successfully applied

## ◆ Apply() [3/4]

std::pair< double, double > GDALGeoTransform::Apply | ( | double | dfPixel,
|  | double | dfLine
| ) |  | const
| inline

Apply GeoTransform to x/y coordinate.

Applies the following computation, converting a (pixel, line) coordinate into a georeferenced (geo_x, geo_y) location.

out.first = padfGeoTransform[0] + dfPixel * padfGeoTransform[1]
+ dfLine * padfGeoTransform[2];
out.second = padfGeoTransform[3] + dfPixel * padfGeoTransform[4]
+ dfLine * padfGeoTransform[5];

Parameters

  dfPixel | Input pixel position.
  dfLine | Input line position.

Returns
  output location as a (geo_x, geo_y) pair

## ◆ Apply() [4/4]

void GDALGeoTransform::Apply | ( | double | dfPixel,
|  | double | dfLine,
|  | double * | pdfGeoX,
|  | double * | pdfGeoY
| ) |  | const
| inline

Apply GeoTransform to x/y coordinate.

Applies the following computation, converting a (pixel, line) coordinate into a georeferenced (geo_x, geo_y) location.

*pdfGeoX = padfGeoTransform[0] + dfPixel * padfGeoTransform[1]
+ dfLine * padfGeoTransform[2];
*pdfGeoY = padfGeoTransform[3] + dfPixel * padfGeoTransform[4]
+ dfLine * padfGeoTransform[5];

Parameters

  dfPixel | Input pixel position.
  dfLine | Input line position.
  pdfGeoX | output location where geo_x (easting/longitude) location is placed.
  pdfGeoY | output location where geo_y (northing/latitude) location is placed.

## ◆ GetInverse()

bool GDALGeoTransform::GetInverse | ( | GDALGeoTransform & | inverse | ) | const
| inline

Invert Geotransform.

This function will invert a standard 3x2 set of GeoTransform coefficients. This converts the equation from being pixel to geo to being geo to pixel.

Parameters

  [out] | inverse | Output geotransform

Returns
  true on success or false if the equation is uninvertable.

## ◆ operator[]() [1/2]

template<typename T >

double & GDALGeoTransform::operator[] | ( | T | idx | ) |
| inline

Element accessor.

idx must be in [0,5] range

## ◆ operator[]() [2/2]

template<typename T >

double GDALGeoTransform::operator[] | ( | T | idx | ) | const
| inline

Element accessor.

idx must be in [0,5] range

## ◆ Rescale()

void GDALGeoTransform::Rescale | ( | double | dfXRatio,
|  | double | dfYRatio
| ) |  |
| inline

Rescale a geotransform by multiplying its scale and rotation terms by the provided ratios.

This is typically used to compute the geotransform matrix of an overview dataset from the full resolution dataset, where the ratios are the size of the full resolution dataset divided by the size of the overview.

The documentation for this class was generated from the following files:

- gdal_geotransform.h
- gdal_misc.cpp