pktools
2.6.7
Processing Kernel for geospatial data
|
#include <ImgRasterGdal.h>
Public Member Functions | |
ImgRasterGdal (void) | |
default constructor | |
virtual | ~ImgRasterGdal (void) |
destructor | |
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. | |
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. | |
virtual void | close (void) |
Close the image. | |
std::string | getFileName () const |
Get the filename of this dataset. | |
int | nrOfCol (void) const |
Get the number of columns of this dataset. | |
int | nrOfRow (void) const |
Get the number of rows of this dataset. | |
int | nrOfBand (void) const |
Get the number of bands of this dataset. | |
bool | isGeoRef () const |
Is this dataset georeferenced (pixel size in y must be negative) ? | |
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. | |
double | getUly () const |
Get the upper left corner y (georeferenced) coordinate of this dataset. | |
double | getLrx () const |
Get the lower right corner x (georeferenced) coordinate of this dataset. | |
double | getLry () const |
Get the lower right corner y (georeferenced) coordinate of this dataset. | |
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. | |
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. | |
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. | |
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. | |
double | getDeltaY (void) const |
Get the pixel cell spacing in y. | |
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) | |
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 | |
GDALDataset * | m_gds |
instance of the GDAL dataset of this dataset | |
int | m_ncol |
number of columns in this dataset | |
int | m_nrow |
number of rows in this dataset | |
int | m_nband |
number of bands in this dataset | |
GDALDataType | m_dataType |
GDAL data type for this dataset. | |
double | m_gt [6] |
geotransform information of this dataset | |
std::string | m_projection |
std::vector< double > | m_noDataValues |
no data values for this dataset | |
std::vector< double > | m_scale |
Vector containing the scale factor to be applied (one scale value for each band) | |
std::vector< double > | m_offset |
Vector containing the offset factor to be applied (one offset value for each band) | |
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.
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 | 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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){Yres}$
x,y | georeferenced coordinates in x and y |
Definition at line 443 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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){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::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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){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.
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.
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.
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.
std::string ImgRasterGdal::getInterleave | ( | ) | const |
Get the band coding (interleave)
Definition at line 293 of file ImgRasterGdal.cc.
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.
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(){Xres}$ adfGeotransform[2]: $-sin(){Xres}$ adfGeotransform[3]: ULY (upper left Y coordinate) adfGeotransform[4]: $-sin(){Yres}$ adfGeotransform[5]: $-cos(){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.
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.
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.