Loading...
Searching...
No Matches
te::rst::Grid Class Reference

A rectified grid is the spatial support for raster data. More...

#include <Grid.h>

Public Member Functions

te::gm::Coord2D geoToGrid (const double &x, const double &y) const
 Get the grid point associated to a spatial location.
 
void geoToGrid (const double &x, const double &y, double &col, double &row) const
 Get the grid point associated to a spatial location.
 
te::gm::EnvelopegetExtent ()
 Returns the geographic extension of the grid.
 
const te::gm::EnvelopegetExtent () const
 Returns the geographic extension of the grid.
 
const double * getGeoreference () const
 Returns a list of 6 coefficients describing an affine transformation to georeference a grid.
 
unsigned int getNumberOfColumns () const
 Returns the grid number of columns.
 
unsigned int getNumberOfRows () const
 Returns the grid number of rows.
 
double getResolutionX () const
 Returns the grid horizontal (x-axis) resolution.
 
double getResolutionY () const
 Returns the grid vertical (y-axis) resolution.
 
int getSRID () const
 Returns the grid spatial reference system identifier.
 
 Grid (const double geoTrans[], unsigned int nCols, unsigned int nRows, int srid=TE_UNKNOWN_SRS)
 Constructor.
 
 Grid (const Grid &rhs)
 Copy constructor.
 
 Grid (double resX, double resY, te::gm::Envelope *mbr, int srid=TE_UNKNOWN_SRS)
 Constructor.
 
 Grid (unsigned int nCols, unsigned int nRows, double resX, double resY, const te::gm::Coord2D *ulc, int srid=TE_UNKNOWN_SRS)
 Constructor.
 
 Grid (unsigned int nCols, unsigned int nRows, double resX, double resY, te::gm::Envelope *mbr, int srid=TE_UNKNOWN_SRS)
 Constructor.
 
 Grid (unsigned int nCols=0, unsigned int nRows=0, te::gm::Envelope *mbr=0, int srid=TE_UNKNOWN_SRS)
 Constructor.
 
te::gm::Coord2D gridToGeo (const double &col, const double &row) const
 Get the spatial location of a grid point.
 
void gridToGeo (const double &col, const double &row, double &x, double &y) const
 Get the spatial location of a grid point.
 
bool isPointInGrid (unsigned int col, unsigned int row) const
 
Gridoperator= (const Grid &rhs)
 Assignment operator.
 
bool operator== (const Grid &rhs) const
 Equal operator.
 
void setGeoreference (const double geoTrans[], int srid)
 Sets the information needed to georeference the grid using an affine transformation.
 
void setGeoreference (const te::gm::Coord2D &ulLocation, int srid, double resX, double resY)
 Sets the information needed to georeference the grid.
 
void setNumberOfColumns (unsigned int nCols)
 Sets the grid number of columns.
 
void setNumberOfRows (unsigned int nRows)
 Sets the grid number of rows.
 
void setSRID (int srid)
 Just sets the grid spatial reference system identifier.
 
 ~Grid ()
 Destructor.
 

Private Member Functions

bool computeAffineParameters (const double extentWidth, const double extentHeight, const unsigned int nColumns, const unsigned int nRows, const double extentULX, const double extentULY, double *affineParamsPtr, double *inverseAffineParamsPtr) const
 Compute affine parameters from the given input parameters.
 
void computeExtent () const
 Computes the geographic extension of the grid.
 
bool computeInverseParameters (double *const affineParamsPtr, double *inverseAffineParamsPtr) const
 Compute inverse affine parameters.
 

Private Attributes

te::gm::Envelopem_extent
 The grid extent.
 
double m_geoT [6]
 A list of 6 coefficients describing an affine transformation to georeference a grid.
 
double m_geoTInverse [6]
 A list of 6 coefficients describing an inverse affine transformation to georeference a grid.
 
unsigned int m_nCols
 Number of columns.
 
unsigned int m_nRows
 Number of rows.
 
int m_srid
 The associated SRS.
 

Detailed Description

A rectified grid is the spatial support for raster data.

Note
The upper left corner of the upper left pixel is considered the grid extent top-left reference.
Affine transformation:
u = a.x + b.y + c
v = d.x + e.y + f
| x | | a b c | | column |
| y | = | d e f | * | row |
| 1 | | 0 0 1 | | 1 |
Georeference parameters order = [ a b c d e f ]
See also
Raster

Definition at line 68 of file Grid.h.

Constructor & Destructor Documentation

◆ Grid() [1/6]

te::rst::Grid::Grid ( unsigned int nCols = 0,
unsigned int nRows = 0,
te::gm::Envelope * mbr = 0,
int srid = TE_UNKNOWN_SRS )

Constructor.

Parameters
nColsThe number of columns.
nRowsThe number of rows.
sridThe SRS associated to the grid.
mbrThe grid extent. The grid will take the ownership of the given envelope.
Note
If extent is not specified, no georeferencing is assumed.
The grid resolution (x-axis and y-axis) will be computed based on the number of columns/rows and the provided extent.

References TE_UNKNOWN_SRS.

Referenced by Grid(), operator=(), and operator==().

◆ Grid() [2/6]

te::rst::Grid::Grid ( unsigned int nCols,
unsigned int nRows,
double resX,
double resY,
const te::gm::Coord2D * ulc,
int srid = TE_UNKNOWN_SRS )

Constructor.

Parameters
nColsThe number of columns.
nRowsThe number of rows.
resXThe grid horizontal (x-axis) resolution.
resYThe grid vertical (y-axis) resolution.
ulcThe location of the upper-left corner of the upper-left pixel (or cell) of the grid assuming srid as the SRS.
sridThe SRS associated to the grid.
Note
If ulc is not specified, no georeferencing is assumed.

References TE_UNKNOWN_SRS.

◆ Grid() [3/6]

te::rst::Grid::Grid ( unsigned int nCols,
unsigned int nRows,
double resX,
double resY,
te::gm::Envelope * mbr,
int srid = TE_UNKNOWN_SRS )

Constructor.

Parameters
nColsThe number of columns.
nRowsThe number of rows.
resXThe grid horizontal (x-axis) resolution.
resYThe grid vertical (y-axis) resolution.
mbrThe grid extent. The grid will take the ownership of the given envelope.
sridThe SRS associated to the grid.
Note
If extent is not specified, no georeferencing is assumed.

References TE_UNKNOWN_SRS.

◆ Grid() [4/6]

te::rst::Grid::Grid ( double resX,
double resY,
te::gm::Envelope * mbr,
int srid = TE_UNKNOWN_SRS )

Constructor.

Parameters
resXThe grid horizontal (x-axis) resolution.
resYThe grid vertical (y-axis) resolution.
mbrThe grid extent. The grid will take the ownership of the given envelope.
sridThe SRS associated to the grid.
Note
The grid resolution (x-axis and y-axis) will be computed based on the number of columns/rows and the provided extent.

References TE_UNKNOWN_SRS.

◆ Grid() [5/6]

te::rst::Grid::Grid ( const double geoTrans[],
unsigned int nCols,
unsigned int nRows,
int srid = TE_UNKNOWN_SRS )

Constructor.

Parameters
nColsThe number of columns.
nRowsThe number of rows.
geoTrans[]A list of 6 coefficients describing an affine transformation to georeference a grid.
sridThe SRS associated to the grid.
Note
If extent is not specified, no georeferencing is assumed.

References TE_UNKNOWN_SRS.

◆ Grid() [6/6]

te::rst::Grid::Grid ( const Grid & rhs)

Copy constructor.

Parameters
rhsThe right-hand-side object to be used to copy from.

References Grid().

◆ ~Grid()

te::rst::Grid::~Grid ( )

Destructor.

Member Function Documentation

◆ computeAffineParameters()

bool te::rst::Grid::computeAffineParameters ( const double extentWidth,
const double extentHeight,
const unsigned int nColumns,
const unsigned int nRows,
const double extentULX,
const double extentULY,
double * affineParamsPtr,
double * inverseAffineParamsPtr ) const
private

Compute affine parameters from the given input parameters.

Parameters
extentWidthExtent width.
extentHeightExtent height.
nColumnsNumber of columns.
nRowsNumber of rows.
extentULXExtent upper-left X coordinate.
extentULYExtent upper-left Y coordinate.
affineParamsPtrA pointer to a allocated vector of 6 elements where the parameters will be stored.
Returns
true if ok, false on errors.

◆ computeExtent()

void te::rst::Grid::computeExtent ( ) const
private

Computes the geographic extension of the grid.

◆ computeInverseParameters()

bool te::rst::Grid::computeInverseParameters ( double *const affineParamsPtr,
double * inverseAffineParamsPtr ) const
private

Compute inverse affine parameters.

Parameters
affineParamsPtrA pointer to a allocated vector of 6 elements (affine parameters).
inverseAffineParamsPtrA pointer to a allocated vector of 6 elements where the parameters will be stored.
Returns
true if ok, false on errors

◆ geoToGrid() [1/2]

te::gm::Coord2D te::rst::Grid::geoToGrid ( const double & x,
const double & y ) const
inline

Get the grid point associated to a spatial location.

Parameters
xThe spatial x-coordiante.
yThe spatial y-coordiante.
Returns
The grid location.

Definition at line 342 of file Grid.h.

References geoToGrid(), te::gm::Coord2D::x, and te::gm::Coord2D::y.

◆ geoToGrid() [2/2]

void te::rst::Grid::geoToGrid ( const double & x,
const double & y,
double & col,
double & row ) const

Get the grid point associated to a spatial location.

Parameters
xThe spatial x-coordiante.
yThe spatial y-coordiante.
colThe grid point column.
rowThe grid point row.

References geoToGrid().

Referenced by geoToGrid(), geoToGrid(), and te::rst::PolygonIterator< T >::initialize().

◆ getExtent() [1/2]

te::gm::Envelope * te::rst::Grid::getExtent ( )

Returns the geographic extension of the grid.

Referenced by te::rst::PolygonIterator< T >::initialize().

◆ getExtent() [2/2]

const te::gm::Envelope * te::rst::Grid::getExtent ( ) const

Returns the geographic extension of the grid.

◆ getGeoreference()

const double * te::rst::Grid::getGeoreference ( ) const

Returns a list of 6 coefficients describing an affine transformation to georeference a grid.

◆ getNumberOfColumns()

unsigned int te::rst::Grid::getNumberOfColumns ( ) const

Returns the grid number of columns.

Referenced by te::rst::PolygonIterator< T >::initialize().

◆ getNumberOfRows()

unsigned int te::rst::Grid::getNumberOfRows ( ) const

Returns the grid number of rows.

Referenced by te::rst::PolygonIterator< T >::initialize().

◆ getResolutionX()

double te::rst::Grid::getResolutionX ( ) const

Returns the grid horizontal (x-axis) resolution.

◆ getResolutionY()

double te::rst::Grid::getResolutionY ( ) const

Returns the grid vertical (y-axis) resolution.

Referenced by te::rst::PolygonIterator< T >::initialize().

◆ getSRID()

int te::rst::Grid::getSRID ( ) const

Returns the grid spatial reference system identifier.

◆ gridToGeo() [1/2]

te::gm::Coord2D te::rst::Grid::gridToGeo ( const double & col,
const double & row ) const
inline

Get the spatial location of a grid point.

Parameters
colThe grid point column.
rowThe grid point row.
Returns
The spatial location.

Definition at line 335 of file Grid.h.

References gridToGeo(), te::gm::Coord2D::x, and te::gm::Coord2D::y.

◆ gridToGeo() [2/2]

void te::rst::Grid::gridToGeo ( const double & col,
const double & row,
double & x,
double & y ) const

Get the spatial location of a grid point.

Parameters
colThe grid point column.
rowThe grid point row.
xThe spatial location (X axis).
yThe spatial location (Y axis).

References gridToGeo().

Referenced by gridToGeo(), and gridToGeo().

◆ isPointInGrid()

bool te::rst::Grid::isPointInGrid ( unsigned int col,
unsigned int row ) const
inline

Definition at line 349 of file Grid.h.

References m_nCols, and m_nRows.

Referenced by operator==().

◆ operator=()

Grid & te::rst::Grid::operator= ( const Grid & rhs)

Assignment operator.

Parameters
rhsThe right-hand-side object to be used to copy from.
Returns
A reference to this.

References Grid().

◆ operator==()

bool te::rst::Grid::operator== ( const Grid & rhs) const

Equal operator.

Parameters
rhsThe source object to be compared.
Returns
True if the grids have the same exact coordinates, number of cols and rows, srid, and 6 coefficients.

References Grid(), and isPointInGrid().

◆ setGeoreference() [1/2]

void te::rst::Grid::setGeoreference ( const double geoTrans[],
int srid )

Sets the information needed to georeference the grid using an affine transformation.

An affine transformation maps grid point (col,lin) to a spatial location (x,y) using to the following relationship: This method should be used mainly when there is a translation associated to the mapping. Otherwise use the method above.

Parameters
geoTrans[]A list of 6 coefficients describing an affine transformation to georeference a grid.
sridThe SRS id to which the location refers to.

◆ setGeoreference() [2/2]

void te::rst::Grid::setGeoreference ( const te::gm::Coord2D & ulLocation,
int srid,
double resX,
double resY )

Sets the information needed to georeference the grid.

Specifies a transformation that maps a grid point (col, row) to a spatial location (x, y).

This method should be used when there is no translation associated to the mapping.

Parameters
ulLocationThe location of the upper-left corner of the upper-left pixel (or cell) of the grid.
sridThe id of the SRS that the location refers to. \para resX The grid horizontal (x-axis) resolution \para resY The grid vertical (y-axis) resolution

◆ setNumberOfColumns()

void te::rst::Grid::setNumberOfColumns ( unsigned int nCols)

Sets the grid number of columns.

Parameters
nColsThe number of columns.

◆ setNumberOfRows()

void te::rst::Grid::setNumberOfRows ( unsigned int nRows)

Sets the grid number of rows.

Parameters
nRowsThe number of rows.

◆ setSRID()

void te::rst::Grid::setSRID ( int srid)

Just sets the grid spatial reference system identifier.

Member Data Documentation

◆ m_extent

te::gm::Envelope* te::rst::Grid::m_extent
mutableprivate

The grid extent.

Definition at line 292 of file Grid.h.

◆ m_geoT

double te::rst::Grid::m_geoT[6]
private

A list of 6 coefficients describing an affine transformation to georeference a grid.

Definition at line 296 of file Grid.h.

◆ m_geoTInverse

double te::rst::Grid::m_geoTInverse[6]
private

A list of 6 coefficients describing an inverse affine transformation to georeference a grid.

Definition at line 297 of file Grid.h.

◆ m_nCols

unsigned int te::rst::Grid::m_nCols
private

Number of columns.

Definition at line 293 of file Grid.h.

Referenced by isPointInGrid().

◆ m_nRows

unsigned int te::rst::Grid::m_nRows
private

Number of rows.

Definition at line 294 of file Grid.h.

Referenced by isPointInGrid().

◆ m_srid

int te::rst::Grid::m_srid
private

The associated SRS.

Definition at line 295 of file Grid.h.


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