![]() |
pktools 2.6.7
Processing Kernel for geospatial data
|
#include <ImgRasterGdal.h>
Public Member Functions | |
ImgRasterGdal (void) | |
default constructor More... | |
virtual | ~ImgRasterGdal (void) |
destructor More... | |
void | setScale (double theScale, int band=0) |
Set scale for a specific band when writing the raster data values. The scaling and offset are applied on a per band basis. You need to set the scale for each band. More... | |
void | setOffset (double theOffset, int band=0) |
Set offset for a specific band when writing the raster data values. The scaling and offset are applied on a per band basis. You need to set the offset for each band. More... | |
virtual void | close (void) |
Close the image. More... | |
std::string | getFileName () const |
Get the filename of this dataset. More... | |
int | nrOfCol (void) const |
Get the number of columns of this dataset. More... | |
int | nrOfRow (void) const |
Get the number of rows of this dataset. More... | |
int | nrOfBand (void) const |
Get the number of bands of this dataset. More... | |
bool | isGeoRef () const |
Is this dataset georeferenced (pixel size in y must be negative) ? More... | |
std::string | getProjection (void) const |
Get the projection string (deprecated, use getProjectionRef instead) More... | |
std::string | getProjectionRef (void) const |
Get the projection reference. More... | |
std::string | getGeoTransform () const |
Get the geotransform data for this dataset as a string. More... | |
void | getGeoTransform (double *gt) const |
Get the geotransform data for this dataset. More... | |
CPLErr | setGeoTransform (double *gt) |
Set the geotransform data for this dataset. More... | |
void | copyGeoTransform (const ImgRasterGdal &imgSrc) |
Copy geotransform information from another georeferenced image. More... | |
CPLErr | setProjection (const std::string &projection) |
Set the projection for this dataset in well known text (wkt) format. More... | |
CPLErr | setProjectionProj4 (const std::string &projection) |
Set the projection for this dataset from user input (supports epsg:<number> format) More... | |
bool | getBoundingBox (double &ulx, double &uly, double &lrx, double &lry) const |
Get the bounding box of this dataset in georeferenced coordinates. More... | |
bool | getCenterPos (double &x, double &y) const |
Get the center position of this dataset in georeferenced coordinates. More... | |
double | getUlx () const |
Get the upper left corner x (georeferenced) coordinate of this dataset. More... | |
double | getUly () const |
Get the upper left corner y (georeferenced) coordinate of this dataset. More... | |
double | getLrx () const |
Get the lower right corner x (georeferenced) coordinate of this dataset. More... | |
double | getLry () const |
Get the lower right corner y (georeferenced) coordinate of this dataset. More... | |
int | getNoDataValues (std::vector< double > &noDataValues) const |
Get the no data values of this dataset as a standard template library (stl) vector. More... | |
bool | isNoData (double value) const |
Check if value is nodata in this dataset. More... | |
int | pushNoDataValue (double noDataValue) |
Push a no data value for this dataset. More... | |
int | setNoData (const std::vector< double > nodata) |
Set the no data values of this dataset using a standard template library (stl) vector as input. More... | |
CPLErr | GDALSetNoDataValue (double noDataValue, int band=0) |
Set the GDAL (internal) no data value for this data set. Only a single no data value per band is supported. More... | |
bool | covers (double x, double y) const |
Check if a geolocation is covered by this dataset. Only the bounding box is checked, irrespective of no data values. More... | |
bool | covers (double ulx, double uly, double lrx, double lry) const |
Check if a region of interest is (partially) covered by this dataset. Only the bounding box is checked, irrespective of no data values. More... | |
bool | geo2image (double x, double y, double &i, double &j) const |
Convert georeferenced coordinates (x and y) to image coordinates (column and row) More... | |
bool | image2geo (double i, double j, double &x, double &y) const |
Convert image coordinates (column and row) to georeferenced coordinates (x and y) More... | |
double | getDeltaX (void) const |
Get the pixel cell spacing in x. More... | |
double | getDeltaY (void) const |
Get the pixel cell spacing in y. More... | |
GDALDataType | getDataType (int band=0) const |
Get the GDAL datatype for this dataset. More... | |
GDALRasterBand * | getRasterBand (int band=0) const |
Get the GDAL rasterband for this dataset. More... | |
GDALColorTable * | getColorTable (int band=0) const |
Get the GDAL color table for this dataset as an instance of the GDALColorTable class. More... | |
std::string | getDriverDescription () const |
Get the GDAL driver description of this dataset. More... | |
std::string | getImageType () const |
Get the image type (implemented as the driver description) More... | |
std::string | getInterleave () const |
Get the band coding (interleave) More... | |
std::string | getCompression () const |
Get the compression from the metadata of this dataset. More... | |
GDALDataset * | getDataset () |
char ** | getMetadata () |
Get the metadata of this dataset. More... | |
char ** | getMetadata () const |
Get the metadata of this dataset (const version) More... | |
void | getMetadata (std::list< std::string > &metadata) const |
Get the metadata of this dataset in the form of a list of strings (const version) More... | |
std::string | getDescription () const |
Get the image description from the driver of this dataset. More... | |
std::string | getMetadataItem () const |
Get metadata item of this dataset. More... | |
std::string | getImageDescription () const |
Get the image description from the metadata of this dataset. More... | |
int | nrOfBlockX (int band=0) |
int | nrOfBlockY (int band=0) |
Protected Attributes | |
std::string | m_filename |
filename of this dataset More... | |
GDALDataset * | m_gds |
instance of the GDAL dataset of this dataset More... | |
int | m_ncol |
number of columns in this dataset More... | |
int | m_nrow |
number of rows in this dataset More... | |
int | m_nband |
number of bands in this dataset More... | |
GDALDataType | m_dataType |
GDAL data type for this dataset. More... | |
double | m_gt [6] |
geotransform information of this dataset More... | |
std::string | m_projection |
std::vector< double > | m_noDataValues |
no data values for this dataset More... | |
std::vector< double > | m_scale |
Vector containing the scale factor to be applied (one scale value for each band) More... | |
std::vector< double > | m_offset |
Vector containing the offset factor to be applied (one offset value for each band) More... | |
Friends | |
class | ImgReaderGdal |
class | ImgWriterGdal |
Base class for raster dataset (read and write) in a format supported by GDAL. This general raster class is used to store e.g., filename, number of columns, rows and bands of the dataset.
Definition at line 67 of file ImgRasterGdal.h.
ImgRasterGdal::ImgRasterGdal | ( | void | ) |
default constructor
Definition at line 24 of file ImgRasterGdal.cc.
|
virtual |
|
virtual |
Close the image.
Reimplemented in ImgUpdaterGdal, ImgReaderGdal, ImgUpdaterGdal, and ImgWriterGdal.
Definition at line 32 of file ImgRasterGdal.cc.
void ImgRasterGdal::copyGeoTransform | ( | const ImgRasterGdal & | imgSrc | ) |
Copy geotransform information from another georeferenced image.
imgSrc | Use this source image as a template to copy geotranform information |
Definition at line 166 of file ImgRasterGdal.cc.
bool ImgRasterGdal::covers | ( | double | ulx, |
double | uly, | ||
double | lrx, | ||
double | lry | ||
) | const |
Check if a region of interest is (partially) covered by this dataset. Only the bounding box is checked, irrespective of no data values.
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
ulx | upper left coordinate in x |
uly | upper left coordinate in y |
lrx | lower left coordinate in x |
lry | lower left coordinate in y |
Definition at line 467 of file ImgRasterGdal.cc.
bool ImgRasterGdal::covers | ( | double | x, |
double | y | ||
) | const |
Check if a geolocation is covered by this dataset. Only the bounding box is checked, irrespective of no data values.
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
x,y | georeferenced coordinates in x and y |
Definition at line 443 of file ImgRasterGdal.cc.
|
inline |
Set the GDAL (internal) no data value for this data set. Only a single no data value per band is supported.
Definition at line 142 of file ImgRasterGdal.h.
bool ImgRasterGdal::geo2image | ( | double | x, |
double | y, | ||
double & | i, | ||
double & | j | ||
) | const |
Convert georeferenced coordinates (x and y) to image coordinates (column and row)
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
x,y | georeferenced coordinates in x and y |
i,j | image coordinates (can be fraction of pixels) |
Definition at line 387 of file ImgRasterGdal.cc.
bool ImgRasterGdal::getBoundingBox | ( | double & | ulx, |
double & | uly, | ||
double & | lrx, | ||
double & | lry | ||
) | const |
Get the bounding box of this dataset in georeferenced coordinates.
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
ulx | upper left coordinate in x |
uly | upper left coordinate in y |
lrx | lower left coordinate in x |
lry | lower left coordinate in y |
Definition at line 333 of file ImgRasterGdal.cc.
bool ImgRasterGdal::getCenterPos | ( | double & | x, |
double & | y | ||
) | const |
Get the center position of this dataset in georeferenced coordinates.
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
x,y | centre coordinates in x and y |
Definition at line 359 of file ImgRasterGdal.cc.
GDALColorTable * ImgRasterGdal::getColorTable | ( | int | band = 0 | ) | const |
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
band | get GDAL color table for this band (start counting from 0) |
Definition at line 118 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getCompression | ( | ) | const |
Get the compression from the metadata of this dataset.
Definition at line 308 of file ImgRasterGdal.cc.
|
inline |
Definition at line 170 of file ImgRasterGdal.h.
GDALDataType ImgRasterGdal::getDataType | ( | int | band = 0 | ) | const |
Get the GDAL datatype for this dataset.
band | get data type for this band (start counting from 0) |
Definition at line 92 of file ImgRasterGdal.cc.
|
inline |
|
inline |
std::string ImgRasterGdal::getDescription | ( | ) | const |
Get the image description from the driver of this dataset.
Definition at line 254 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getDriverDescription | ( | ) | const |
Get the GDAL driver description of this dataset.
Definition at line 131 of file ImgRasterGdal.cc.
|
inline |
Get the filename of this dataset.
Definition at line 96 of file ImgRasterGdal.h.
std::string ImgRasterGdal::getGeoTransform | ( | ) | const |
Get the geotransform data for this dataset as a string.
Definition at line 200 of file ImgRasterGdal.cc.
void ImgRasterGdal::getGeoTransform | ( | double * | gt | ) | const |
Get the geotransform data for this dataset.
gt | pointer to the six geotransform parameters: |
adfGeoTransform[0] | top left x |
GeoTransform[1] | w-e pixel resolution |
GeoTransform[2] | rotation, 0 if image is "north up" |
GeoTransform[3] | top left y |
GeoTransform[4] | rotation, 0 if image is "north up" |
GeoTransform[5] | n-s pixel resolution |
Definition at line 183 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getImageDescription | ( | ) | const |
Get the image description from the metadata of this dataset.
Definition at line 280 of file ImgRasterGdal.cc.
|
inline |
Get the image type (implemented as the driver description)
Definition at line 164 of file ImgRasterGdal.h.
std::string ImgRasterGdal::getInterleave | ( | ) | const |
Get the band coding (interleave)
Definition at line 293 of file ImgRasterGdal.cc.
|
inline |
Get the lower right corner x (georeferenced) coordinate of this dataset.
Definition at line 130 of file ImgRasterGdal.h.
|
inline |
Get the lower right corner y (georeferenced) coordinate of this dataset.
Definition at line 132 of file ImgRasterGdal.h.
char ** ImgRasterGdal::getMetadata | ( | ) |
Get the metadata of this dataset.
Definition at line 214 of file ImgRasterGdal.cc.
char ** ImgRasterGdal::getMetadata | ( | ) | const |
Get the metadata of this dataset (const version)
Definition at line 227 of file ImgRasterGdal.cc.
void ImgRasterGdal::getMetadata | ( | std::list< std::string > & | metadata | ) | const |
Get the metadata of this dataset in the form of a list of strings (const version)
Definition at line 240 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getMetadataItem | ( | ) | const |
Get metadata item of this dataset.
Definition at line 267 of file ImgRasterGdal.cc.
int ImgRasterGdal::getNoDataValues | ( | std::vector< double > & | noDataValues | ) | const |
Get the no data values of this dataset as a standard template library (stl) vector.
noDataValues | standard template library (stl) vector containing no data values |
Definition at line 478 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getProjection | ( | void | ) | const |
Get the projection string (deprecated, use getProjectionRef instead)
Definition at line 40 of file ImgRasterGdal.cc.
std::string ImgRasterGdal::getProjectionRef | ( | void | ) | const |
Get the projection reference.
Definition at line 51 of file ImgRasterGdal.cc.
GDALRasterBand * ImgRasterGdal::getRasterBand | ( | int | band = 0 | ) | const |
Get the GDAL rasterband for this dataset.
band | get GDAL raster band for this band (start counting from 0) |
Definition at line 105 of file ImgRasterGdal.cc.
|
inline |
Get the upper left corner x (georeferenced) coordinate of this dataset.
Definition at line 126 of file ImgRasterGdal.h.
|
inline |
Get the upper left corner y (georeferenced) coordinate of this dataset.
Definition at line 128 of file ImgRasterGdal.h.
bool ImgRasterGdal::image2geo | ( | double | i, |
double | j, | ||
double & | x, | ||
double & | y | ||
) | const |
Convert image coordinates (column and row) to georeferenced coordinates (x and y)
assuming adfGeotransform[0]: ULX (upper left X coordinate) adfGeotransform[1]: $cos(\alpha)\cdot\textrm{Xres}$ adfGeotransform[2]: $-sin(\alpha)\cdot\textrm{Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(\alpha)\cdot\textrm{Yres}$ adfGeotransform[5]: $-cos(\alpha)\cdot\textrm{Yres}$
i,j | image coordinates (can be fraction of pixels) |
x,y | georeferenced coordinates in x and y (can be fraction of pixels) |
Definition at line 416 of file ImgRasterGdal.cc.
|
inline |
Is this dataset georeferenced (pixel size in y must be negative) ?
Definition at line 104 of file ImgRasterGdal.h.
|
inline |
Check if value is nodata in this dataset.
Definition at line 136 of file ImgRasterGdal.h.
|
inline |
|
inline |
Definition at line 183 of file ImgRasterGdal.h.
|
inline |
Definition at line 190 of file ImgRasterGdal.h.
|
inline |
|
inline |
int ImgRasterGdal::pushNoDataValue | ( | double | noDataValue | ) |
Push a no data value for this dataset.
noDataValue | no data value to be pushed for this dataset |
Definition at line 492 of file ImgRasterGdal.cc.
CPLErr ImgRasterGdal::setGeoTransform | ( | double * | gt | ) |
Set the geotransform data for this dataset.
gt | pointer to the six geotransform parameters: |
adfGeoTransform[0] | top left x |
GeoTransform[1] | w-e pixel resolution |
GeoTransform[2] | rotation, 0 if image is "north up" |
GeoTransform[3] | top left y |
GeoTransform[4] | rotation, 0 if image is "north up" |
GeoTransform[5] | n-s pixel resolution |
Definition at line 148 of file ImgRasterGdal.cc.
|
inline |
Set the no data values of this dataset using a standard template library (stl) vector as input.
Definition at line 140 of file ImgRasterGdal.h.
|
inline |
Set offset for a specific band when writing the raster data values. The scaling and offset are applied on a per band basis. You need to set the offset for each band.
Definition at line 84 of file ImgRasterGdal.h.
CPLErr ImgRasterGdal::setProjection | ( | const std::string & | projection | ) |
Set the projection for this dataset in well known text (wkt) format.
projection | projection string to be used for this dataset |
Definition at line 79 of file ImgRasterGdal.cc.
CPLErr ImgRasterGdal::setProjectionProj4 | ( | const std::string & | projection | ) |
Set the projection for this dataset from user input (supports epsg:<number> format)
projection | projection string to be used for this dataset |
Definition at line 63 of file ImgRasterGdal.cc.
|
inline |
Set scale for a specific band when writing the raster data values. The scaling and offset are applied on a per band basis. You need to set the scale for each band.
Definition at line 75 of file ImgRasterGdal.h.
|
friend |
Definition at line 198 of file ImgRasterGdal.h.
|
friend |
Definition at line 199 of file ImgRasterGdal.h.
|
protected |
GDAL data type for this dataset.
Definition at line 213 of file ImgRasterGdal.h.
|
protected |
filename of this dataset
Definition at line 203 of file ImgRasterGdal.h.
|
protected |
instance of the GDAL dataset of this dataset
Definition at line 205 of file ImgRasterGdal.h.
|
protected |
geotransform information of this dataset
Definition at line 215 of file ImgRasterGdal.h.
|
protected |
number of bands in this dataset
Definition at line 211 of file ImgRasterGdal.h.
|
protected |
number of columns in this dataset
Definition at line 207 of file ImgRasterGdal.h.
|
protected |
no data values for this dataset
Definition at line 219 of file ImgRasterGdal.h.
|
protected |
number of rows in this dataset
Definition at line 209 of file ImgRasterGdal.h.
|
protected |
Vector containing the offset factor to be applied (one offset value for each band)
Definition at line 223 of file ImgRasterGdal.h.
|
protected |
Definition at line 217 of file ImgRasterGdal.h.
|
protected |
Vector containing the scale factor to be applied (one scale value for each band)
Definition at line 221 of file ImgRasterGdal.h.