pktools  2.6.7
Processing Kernel for geospatial data
Public Member Functions | Protected Attributes | Friends | List of all members
ImgRasterGdal Class Reference

#include <ImgRasterGdal.h>

Inheritance diagram for ImgRasterGdal:
Inheritance graph
[legend]
Collaboration diagram for ImgRasterGdal:
Collaboration graph
[legend]

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
 

Detailed Description

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.

Member Function Documentation

◆ copyGeoTransform()

void ImgRasterGdal::copyGeoTransform ( const ImgRasterGdal imgSrc)

Copy geotransform information from another georeferenced image.

Parameters
imgSrcUse this source image as a template to copy geotranform information

Definition at line 166 of file ImgRasterGdal.cc.

167 {
168  setProjection(imgSrc.getProjection());
169  double gt[6];
170  imgSrc.getGeoTransform(gt);
171  setGeoTransform(gt);
172 }
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ covers() [1/2]

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}$

Parameters
x,ygeoreferenced coordinates in x and y
Returns
true if image covers the georeferenced location

Definition at line 443 of file ImgRasterGdal.cc.

444 {
445  double theULX, theULY, theLRX, theLRY;
446  getBoundingBox(theULX,theULY,theLRX,theLRY);
447  return((x > theULX)&&
448  (x < theLRX)&&
449  (y < theULY)&&
450  (y >theLRY));
451 }
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.

◆ covers() [2/2]

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}$

Parameters
ulxupper left coordinate in x
ulyupper left coordinate in y
lrxlower left coordinate in x
lrylower left coordinate in y
Returns
true if image (partially) covers the bounding box

Definition at line 467 of file ImgRasterGdal.cc.

468 {
469  double theULX, theULY, theLRX, theLRY;
470  getBoundingBox(theULX,theULY,theLRX,theLRY);
471  return((ulx < theLRX)&&(lrx > theULX)&&(lry < theULY)&&(uly > theLRY));
472 }
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.

◆ geo2image()

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}$

Parameters
x,ygeoreferenced coordinates in x and y
i,jimage coordinates (can be fraction of pixels)
Returns
true if image is georeferenced

Definition at line 387 of file ImgRasterGdal.cc.

388 {
389  double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
390  getGeoTransform(gt);
391 
392  double denom=(gt[1]-gt[2]*gt[4]/gt[5]);
393  double eps=0.00001;
394  if(fabs(denom)>eps){
395  i=(x-gt[0]-gt[2]/gt[5]*(y-gt[3]))/denom;
396  j=(y-gt[3]-gt[4]*(x-gt[0]-gt[2]/gt[5]*(y-gt[3]))/denom)/gt[5];
397  }
398  if(isGeoRef())
399  return true;
400  else
401  return false;
402 }
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ getBoundingBox()

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}$

Parameters
ulxupper left coordinate in x
ulyupper left coordinate in y
lrxlower left coordinate in x
lrylower left coordinate in y
Returns
true if image is georeferenced

Definition at line 333 of file ImgRasterGdal.cc.

334 {
335  double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
336  getGeoTransform(gt);
337 
338  ulx=gt[0];
339  uly=gt[3];
340  lrx=gt[0]+nrOfCol()*gt[1]+nrOfRow()*gt[2];
341  lry=gt[3]+nrOfCol()*gt[4]+nrOfRow()*gt[5];
342  if(isGeoRef())
343  return true;
344  else
345  return false;
346 }
int nrOfCol(void) const
Get the number of columns of this dataset.
Definition: ImgRasterGdal.h:98
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 getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ getCenterPos()

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}$

Parameters
x,ycentre coordinates in x and y
Returns
true if image is georeferenced

Definition at line 359 of file ImgRasterGdal.cc.

360 {
361  double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
362  getGeoTransform(gt);
363 
364  x=gt[0]+(nrOfCol()/2.0)*gt[1]+(nrOfRow()/2.0)*gt[2];
365  y=gt[3]+(nrOfCol()/2.0)*gt[4]+(nrOfRow()/2.0)*gt[5];
366  if(isGeoRef()){
367  // x=m_ulx+(nrOfCol()/2.0)*m_delta_x;
368  // y=m_uly-(nrOfRow()/2.0)*m_delta_y;
369  return true;
370  }
371  else
372  return false;
373 }
int nrOfCol(void) const
Get the number of columns of this dataset.
Definition: ImgRasterGdal.h:98
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 getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ getColorTable()

GDALColorTable * ImgRasterGdal::getColorTable ( int  band = 0) const

Get the GDAL color table for this dataset as an instance of the GDALColorTable class.

Parameters
bandget GDAL color table for this band (start counting from 0)
Returns
the GDAL color table of this data set for the selected band

Definition at line 118 of file ImgRasterGdal.cc.

119 {
120  assert(band<m_nband+1);
121  GDALRasterBand* theRasterBand=getRasterBand(band);
122  if(theRasterBand)
123  return(theRasterBand->GetColorTable());
124  else
125  return(0);
126 }
int m_nband
number of bands in this dataset
GDALRasterBand * getRasterBand(int band=0) const
Get the GDAL rasterband for this dataset.

◆ getCompression()

std::string ImgRasterGdal::getCompression ( ) const

Get the compression from the metadata of this dataset.

Returns
the compression meta data of this data set in string format

Definition at line 308 of file ImgRasterGdal.cc.

309 {
310  if(m_gds){
311  if(m_gds->GetMetadataItem( "COMPRESSION", "IMAGE_STRUCTURE"))
312  return m_gds->GetMetadataItem( "COMPRESSION", "IMAGE_STRUCTURE");
313  }
314  else
315  return("NONE");
316 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getDataType()

GDALDataType ImgRasterGdal::getDataType ( int  band = 0) const

Get the GDAL datatype for this dataset.

Parameters
bandget data type for this band (start counting from 0)
Returns
the GDAL data type of this data set for the selected band

Definition at line 92 of file ImgRasterGdal.cc.

93 {
94  assert(band<m_nband+1);
95  if(getRasterBand(band))
96  return((getRasterBand(band)->GetRasterDataType()));
97  else
98  return(m_dataType);
99 }
GDALDataType m_dataType
GDAL data type for this dataset.
int m_nband
number of bands in this dataset
GDALRasterBand * getRasterBand(int band=0) const
Get the GDAL rasterband for this dataset.

◆ getDescription()

std::string ImgRasterGdal::getDescription ( ) const

Get the image description from the driver of this dataset.

Returns
the description of this data set in string format

Definition at line 254 of file ImgRasterGdal.cc.

255 {
256  if(m_gds){
257  if(m_gds->GetDriver()->GetDescription()!=NULL)
258  return m_gds->GetDriver()->GetDescription();
259  }
260  else
261  return("");
262 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getDriverDescription()

std::string ImgRasterGdal::getDriverDescription ( ) const

Get the GDAL driver description of this dataset.

Returns
the driver description of this data set in string format

Definition at line 131 of file ImgRasterGdal.cc.

132 {
133  std::string driverDescription;
134  if(m_gds)
135  driverDescription=m_gds->GetDriver()->GetDescription();
136  return(driverDescription);
137 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getGeoTransform() [1/2]

std::string ImgRasterGdal::getGeoTransform ( ) const

Get the geotransform data for this dataset as a string.

Returns
the geotransform of this data set in string format

Definition at line 200 of file ImgRasterGdal.cc.

201 {
202  std::string gtString;
203  double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
204  getGeoTransform(gt);
205  std::ostringstream s;
206  s << "[" << gt[0] << "," << gt[1] << "," << gt[2] << "," << gt[3] << "," << gt[4] << "," << gt[5] << "]";
207  gtString=s.str();
208  return(s.str());
209 }
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ getGeoTransform() [2/2]

void ImgRasterGdal::getGeoTransform ( double *  gt) const

Get the geotransform data for this dataset.

Parameters
gtpointer 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.

183  {
184  // if(m_gds){
185  // m_gds->GetGeoTransform(gt);
186  // }
187  // else{
188  gt[0]=m_gt[0];
189  gt[1]=m_gt[1];
190  gt[2]=m_gt[2];
191  gt[3]=m_gt[3];
192  gt[4]=m_gt[4];
193  gt[5]=m_gt[5];
194  // }
195 }
double m_gt[6]
geotransform information of this dataset

◆ getImageDescription()

std::string ImgRasterGdal::getImageDescription ( ) const

Get the image description from the metadata of this dataset.

Returns
the image description (TIFFTAG) of this data set in string format

Definition at line 280 of file ImgRasterGdal.cc.

281 {
282  if(m_gds){
283  if(m_gds->GetDriver()->GetMetadataItem("TIFFTAG_IMAGEDESCRIPTION")!=NULL)
284  return m_gds->GetDriver()->GetMetadataItem("TIFFTAG_IMAGEDESCRIPTION");
285  }
286  else
287  return("");
288 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getInterleave()

std::string ImgRasterGdal::getInterleave ( ) const

Get the band coding (interleave)

Returns
the band coding interleave of this data set in string format

Definition at line 293 of file ImgRasterGdal.cc.

294 {
295  if(m_gds){
296  if(m_gds->GetMetadataItem( "INTERLEAVE", "IMAGE_STRUCTURE"))
297  return m_gds->GetMetadataItem( "INTERLEAVE", "IMAGE_STRUCTURE");
298  else
299  return("BAND");
300  }
301  else
302  return("");
303 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getMetadata() [1/3]

char ** ImgRasterGdal::getMetadata ( )

Get the metadata of this dataset.

Returns
the metadata of this data set in string format

Definition at line 214 of file ImgRasterGdal.cc.

215 {
216  if(m_gds){
217  if(m_gds->GetMetadata()!=NULL)
218  return(m_gds->GetMetadata());
219  }
220  else
221  return (char**)"";
222 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getMetadata() [2/3]

char ** ImgRasterGdal::getMetadata ( ) const

Get the metadata of this dataset (const version)

Returns
the metadata of this data set in C style string format (const version)

Definition at line 227 of file ImgRasterGdal.cc.

228 {
229  if(m_gds){
230  if(m_gds->GetMetadata()!=NULL)
231  return(m_gds->GetMetadata());
232  }
233  else
234  return (char**)"";
235 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getMetadata() [3/3]

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)

Returns
the metadata of this data set in standard template library (stl) string format

Definition at line 240 of file ImgRasterGdal.cc.

241 {
242  if(m_gds){
243  char** cmetadata=m_gds->GetMetadata();
244  while(*cmetadata!=NULL){
245  metadata.push_back(*(cmetadata));
246  ++cmetadata;
247  }
248  }
249 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getMetadataItem()

std::string ImgRasterGdal::getMetadataItem ( ) const

Get metadata item of this dataset.

Returns
the meta data item of this data set in string format

Definition at line 267 of file ImgRasterGdal.cc.

268 {
269  if(m_gds){
270  if(m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME )!=NULL)
271  return m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME );
272  }
273  else
274  return("");
275 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ getNoDataValues()

int ImgRasterGdal::getNoDataValues ( std::vector< double > &  noDataValues) const

Get the no data values of this dataset as a standard template library (stl) vector.

Parameters
noDataValuesstandard template library (stl) vector containing no data values
Returns
number of no data values in this dataset

Definition at line 478 of file ImgRasterGdal.cc.

479 {
480  if(m_noDataValues.size()){
481  noDataValues=m_noDataValues;
482  return m_noDataValues.size();
483  }
484  else
485  return 0;
486 }
std::vector< double > m_noDataValues
no data values for this dataset

◆ getProjection()

std::string ImgRasterGdal::getProjection ( void  ) const

Get the projection string (deprecated, use getProjectionRef instead)

Returns
the projection of this data set in string format

Definition at line 40 of file ImgRasterGdal.cc.

41 {
42  // if(m_gds)
43  // return(m_gds->GetProjectionRef());
44  // else
45  return(m_projection);
46 }

◆ getProjectionRef()

std::string ImgRasterGdal::getProjectionRef ( void  ) const

Get the projection reference.

Returns
the projection of this data set in string format

Definition at line 51 of file ImgRasterGdal.cc.

52 {
53  // if(m_gds)
54  // return(m_gds->GetProjectionRef());
55  // else
56  return(m_projection);
57 }

◆ getRasterBand()

GDALRasterBand * ImgRasterGdal::getRasterBand ( int  band = 0) const

Get the GDAL rasterband for this dataset.

Parameters
bandget GDAL raster band for this band (start counting from 0)
Returns
the GDAL raster band of this data set for the selected band

Definition at line 105 of file ImgRasterGdal.cc.

106 {
107  assert(band<m_nband+1);
108  if(m_gds)
109  return((m_gds->GetRasterBand(band+1)));
110  else
111  return(0);
112 }
int m_nband
number of bands in this dataset
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ image2geo()

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}$

Parameters
i,jimage coordinates (can be fraction of pixels)
x,ygeoreferenced coordinates in x and y (can be fraction of pixels)
Returns
true if image is georeferenced

Definition at line 416 of file ImgRasterGdal.cc.

417 {
418  double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
419  getGeoTransform(gt);
420 
421  x=gt[0]+(0.5+i)*gt[1]+(0.5+j)*gt[2];
422  y=gt[3]+(0.5+i)*gt[4]+(0.5+j)*gt[5];
423  if(isGeoRef()){
424  // x=m_ulx+(0.5+i)*m_delta_x;
425  // y=m_uly-(0.5+j)*m_delta_y;
426  return true;
427  }
428  else
429  return false;
430 }
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.

◆ pushNoDataValue()

int ImgRasterGdal::pushNoDataValue ( double  noDataValue)

Push a no data value for this dataset.

Parameters
noDataValueno data value to be pushed for this dataset
Returns
number of no data values in this dataset

Definition at line 492 of file ImgRasterGdal.cc.

493 {
494  if(find(m_noDataValues.begin(),m_noDataValues.end(),noDataValue)==m_noDataValues.end())
495  m_noDataValues.push_back(noDataValue);
496  return(m_noDataValues.size());
497 }
std::vector< double > m_noDataValues
no data values for this dataset

◆ setGeoTransform()

CPLErr ImgRasterGdal::setGeoTransform ( double *  gt)

Set the geotransform data for this dataset.

Parameters
gtpointer 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.

148  {
149  // m_isGeoRef=true;
150  m_gt[0]=gt[0];
151  m_gt[1]=gt[1];
152  m_gt[2]=gt[2];
153  m_gt[3]=gt[3];
154  m_gt[4]=gt[4];
155  m_gt[5]=gt[5];
156  if(m_gds)
157  return(m_gds->SetGeoTransform(m_gt));
158  else
159  return(CE_Failure);
160 
161 }
double m_gt[6]
geotransform information of this dataset
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ setProjection()

CPLErr ImgRasterGdal::setProjection ( const std::string &  projection)

Set the projection for this dataset in well known text (wkt) format.

Parameters
projectionprojection string to be used for this dataset

Definition at line 79 of file ImgRasterGdal.cc.

80 {
81  m_projection=projection;
82  if(m_gds)
83  return(m_gds->SetProjection(projection.c_str()));
84  else
85  return(CE_Failure);
86 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

◆ setProjectionProj4()

CPLErr ImgRasterGdal::setProjectionProj4 ( const std::string &  projection)

Set the projection for this dataset from user input (supports epsg:<number> format)

Parameters
projectionprojection string to be used for this dataset
Returns
the projection of this data set in string format

Definition at line 63 of file ImgRasterGdal.cc.

64 {
65  OGRSpatialReference theRef;
66  theRef.SetFromUserInput(projection.c_str());
67  char *wktString;
68  theRef.exportToWkt(&wktString);
69  m_projection=wktString;
70  if(m_gds)
71  return(m_gds->SetProjection(wktString));
72  else
73  return(CE_Failure);
74 }
GDALDataset * m_gds
instance of the GDAL dataset of this dataset

The documentation for this class was generated from the following files: