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
std::string getDriverDescription() const
Get the GDAL driver description of this dataset.
virtual ~ImgRasterGdal(void)
destructor
GDALDataType m_dataType
GDAL data type for this dataset.
double getLry() const
Get the lower right corner y (georeferenced) coordinate of this dataset.
int m_nband
number of bands in this dataset
std::string getImageDescription() const
Get the image description from the metadata of this dataset.
std::string getProjectionRef(void) const
Get the projection reference.
std::string getFileName() const
Get the filename of 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...
bool isNoData(double value) const
Check if value is nodata in 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) ...
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
int nrOfBand(void) const
Get the number of bands of this dataset.
GDALDataType getDataType(int band=0) const
Get the GDAL datatype for this dataset.
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
int getNoDataValues(std::vector< double > &noDataValues) const
Get the no data values of this dataset as a standard template library (stl) vector.
CPLErr setProjectionProj4(const std::string &projection)
Set the projection for this dataset from user input (supports epsg: format) ...
std::string getMetadataItem() const
Get metadata item of this dataset.
std::string m_filename
filename of this dataset
std::vector< double > m_noDataValues
no data values for this dataset
double m_gt[6]
geotransform information of this dataset
int nrOfRow(void) const
Get the number of rows of this dataset.
GDALDataset * m_gds
instance of the GDAL dataset of this dataset
double getUly() const
Get the upper left corner y (georeferenced) coordinate of this dataset.
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.
bool image2geo(double i, double j, double &x, double &y) const
Convert image coordinates (column and row) to georeferenced coordinates (x and y) ...
std::string getDescription() const
Get the image description from the driver of this dataset.
double getDeltaY(void) const
Get the pixel cell spacing in y.
std::string getImageType() const
Get the image type (implemented as the driver description)
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
double getLrx() const
Get the lower right corner x (georeferenced) coordinate of this dataset.
int m_nrow
number of rows in this dataset
int pushNoDataValue(double noDataValue)
Push a no data value for this dataset.
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.
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
std::string getCompression() const
Get the compression from the metadata of this dataset.
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...
virtual void close(void)
Close the image.
double getUlx() const
Get the upper left corner x (georeferenced) coordinate of this dataset.
double getDeltaX(void) const
Get the pixel cell spacing in x.
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
bool getCenterPos(double &x, double &y) const
Get the center position of this dataset in georeferenced coordinates.
std::string getInterleave() const
Get the band coding (interleave)
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
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...
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_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 nrOfCol(void) const
Get the number of columns of this dataset.