20 #ifndef _IMGRASTERGDAL_H_ 21 #define _IMGRASTERGDAL_H_ 31 #include "gdal_priv.h" 33 enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };
39 template<
typename T1> GDALDataType getGDALDataType(){
40 if (
typeid(T1) ==
typeid(
char))
42 else if (
typeid(T1) ==
typeid(
unsigned char))
44 else if (
typeid(T1) ==
typeid(
unsigned short))
46 else if (
typeid(T1) ==
typeid(
short))
48 else if (
typeid(T1) ==
typeid(
int))
50 else if (
typeid(T1) ==
typeid(
unsigned int))
52 else if (
typeid(T1) ==
typeid(
long))
54 else if (
typeid(T1) ==
typeid(
unsigned long))
56 else if (
typeid(T1) ==
typeid(
float))
58 else if (
typeid(T1) ==
typeid(
double))
78 for(
int iband=0;iband<
nrOfBand();++iband)
87 for(
int iband=0;iband<
nrOfBand();++iband)
94 virtual void close(
void);
122 bool getBoundingBox (
double& ulx,
double& uly,
double& lrx,
double& lry)
const;
144 bool covers(
double x,
double y)
const;
146 bool covers(
double ulx,
double uly,
double lrx,
double lry)
const;
148 bool geo2image(
double x,
double y,
double& i,
double& j)
const;
150 bool image2geo(
double i,
double j,
double& x,
double& y)
const;
170 GDALDataset* getDataset(){
return m_gds;};
176 void getMetadata(std::list<std::string>& metadata)
const;
183 int nrOfBlockX(
int band=0)
185 int nXBlockSize, nYBlockSize;
186 getRasterBand(band)->GetBlockSize( &nXBlockSize, &nYBlockSize );
187 int nXBlocks = (
nrOfCol() + nXBlockSize - 1) / nXBlockSize;
190 int nrOfBlockY(
int band=0)
192 int nXBlockSize, nYBlockSize;
193 getRasterBand(band)->GetBlockSize( &nXBlockSize, &nYBlockSize );
194 int nYBlocks = (
nrOfRow() + nYBlockSize - 1) / nYBlockSize;
217 std::string m_projection;
228 #endif // _IMGRASTERGDAL_H_
ImgRasterGdal(void)
default constructor
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.
double getLry() const
Get the lower right corner y (georeferenced) coordinate of this dataset.
virtual ~ImgRasterGdal(void)
destructor
GDALDataType m_dataType
GDAL data type for this dataset.
std::string getDescription() const
Get the image description from the driver of this dataset.
int m_nband
number of bands in this dataset
void setOffset(double theOffset, int band=0)
Set offset for a specific band when writing the raster data values. The scaling and offset are applie...
double getUly() const
Get the upper left corner y (georeferenced) coordinate of this dataset.
bool geo2image(double x, double y, double &i, double &j) const
Convert georeferenced coordinates (x and y) to image coordinates (column and row) ...
std::string getMetadataItem() const
Get metadata item of this dataset.
bool isNoData(double value) const
Check if value is nodata in this dataset.
CPLErr setProjectionProj4(const std::string &projection)
Set the projection for this dataset from user input (supports epsg:<number> format) ...
int nrOfCol(void) const
Get the number of columns of this dataset.
std::string m_filename
filename of this dataset
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.
std::vector< double > m_noDataValues
no data values for this dataset
double m_gt[6]
geotransform information of this dataset
GDALDataset * m_gds
instance of the GDAL dataset of this dataset
std::string getDriverDescription() const
Get the GDAL driver description of this dataset.
double getUlx() const
Get the upper left corner x (georeferenced) coordinate of this dataset.
int nrOfRow(void) const
Get the number of rows of this dataset.
bool getCenterPos(double &x, double &y) const
Get the center position of this dataset in georeferenced coordinates.
bool image2geo(double i, double j, double &x, double &y) const
Convert image coordinates (column and row) to georeferenced coordinates (x and y) ...
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
std::string getImageDescription() const
Get the image description from the metadata of this dataset.
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
std::string getImageType() const
Get the image type (implemented as the driver description)
double getLrx() const
Get the lower right corner x (georeferenced) coordinate of this dataset.
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
int m_nrow
number of rows in this dataset
double getDeltaX(void) const
Get the pixel cell spacing in x.
int pushNoDataValue(double noDataValue)
Push a no data value for this dataset.
char ** getMetadata()
Get the metadata of this dataset.
void copyGeoTransform(const ImgRasterGdal &imgSrc)
Copy geotransform information from another georeferenced image.
int m_ncol
number of columns in this dataset
double getDeltaY(void) const
Get the pixel cell spacing in y.
std::vector< double > m_scale
Vector containing the scale factor to be applied (one scale value for each band)
int setNoData(const std::vector< double > nodata)
Set the no data values of this dataset using a standard template library (stl) vector as input...
std::string getCompression() const
Get the compression from the metadata of this dataset.
virtual void close(void)
Close the image.
std::string getFileName() const
Get the filename of this dataset.
std::string getProjectionRef(void) const
Get the projection reference.
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
GDALDataType getDataType(int band=0) const
Get the GDAL datatype for this dataset.
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
GDALRasterBand * getRasterBand(int band=0) const
Get the GDAL rasterband for this dataset.
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.
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 supp...
int nrOfBand(void) const
Get the number of bands of this dataset.
std::vector< double > m_offset
Vector containing the offset factor to be applied (one offset value for each band) ...
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...
int getNoDataValues(std::vector< double > &noDataValues) const
Get the no data values of this dataset as a standard template library (stl) vector.
std::string getInterleave() const
Get the band coding (interleave)