20#ifndef _IMGRASTERGDAL_H_
21#define _IMGRASTERGDAL_H_
33enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };
39template<
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;
double getDeltaY(void) const
Get the pixel cell spacing in y.
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.
int nrOfRow(void) const
Get the number of rows of this dataset.
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
std::string getDriverDescription() const
Get the GDAL driver description 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)
bool getCenterPos(double &x, double &y) const
Get the center position of this dataset in georeferenced coordinates.
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
int m_nband
number of bands in this dataset
int m_ncol
number of columns in this dataset
bool isNoData(double value) const
Check if value is nodata in this dataset.
std::string m_filename
filename of this dataset
double getUly() const
Get the upper left corner y (georeferenced) coordinate of this dataset.
char ** getMetadata()
Get the metadata 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.
GDALDataset * m_gds
instance of the GDAL dataset of this dataset
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
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 nrOfBand(void) const
Get the number of bands of this dataset.
std::string getCompression() const
Get the compression from the metadata of this dataset.
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...
void copyGeoTransform(const ImgRasterGdal &imgSrc)
Copy geotransform information from another georeferenced image.
int m_nrow
number of rows in this dataset
std::vector< double > m_offset
Vector containing the offset factor to be applied (one offset value for each band)
std::string getProjectionRef(void) const
Get the projection reference.
virtual ~ImgRasterGdal(void)
destructor
CPLErr setProjectionProj4(const std::string &projection)
Set the projection for this dataset from user input (supports epsg:<number> format)
std::string getImageDescription() const
Get the image description from the metadata of this dataset.
int nrOfCol(void) const
Get the number of columns of this dataset.
double getDeltaX(void) const
Get the pixel cell spacing in x.
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...
std::vector< double > m_noDataValues
no data values for this dataset
std::string getInterleave() const
Get the band coding (interleave)
GDALRasterBand * getRasterBand(int band=0) const
Get the GDAL rasterband for this dataset.
ImgRasterGdal(void)
default constructor
int pushNoDataValue(double noDataValue)
Push a no data value for this dataset.
double getLry() const
Get the lower right corner y (georeferenced) coordinate of this dataset.
std::vector< double > m_scale
Vector containing the scale factor to be applied (one scale value for each band)
bool image2geo(double i, double j, double &x, double &y) const
Convert image coordinates (column and row) to georeferenced coordinates (x and y)
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...
std::string getImageType() const
Get the image type (implemented as the driver description)
std::string getMetadataItem() const
Get metadata item of this dataset.
double m_gt[6]
geotransform information of this dataset
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.
bool covers(double x, double y) const
Check if a geolocation is covered by this dataset. Only the bounding box is checked,...
GDALDataType m_dataType
GDAL data type for this dataset.
std::string getFileName() const
Get the filename of this dataset.
double getUlx() const
Get the upper left corner x (georeferenced) coordinate of this dataset.
std::string getDescription() const
Get the image description from the driver of this dataset.
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.