pktools  2.6.7
Processing Kernel for geospatial data
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ImgUpdaterGdal Class Reference
Inheritance diagram for ImgUpdaterGdal:
Inheritance graph
[legend]
Collaboration diagram for ImgUpdaterGdal:
Collaboration graph
[legend]

Public Member Functions

 ImgUpdaterGdal (const std::string &filename)
 
void open (const std::string &filename)
 
void close (void)
 Close the image.
 
 ImgUpdaterGdal (void)
 default constructor. Image needs to be opened later with one of the open methods.
 
 ImgUpdaterGdal (const std::string &filename, const GDALAccess &readMode=GA_Update)
 constructor opening an image in update mode (read and write). More...
 
 ~ImgUpdaterGdal (void)
 destructor
 
void open (const std::string &filename, const GDALAccess &readMode=GA_Update)
 Open an image in update mode (read and write). More...
 
void close (void)
 close the image
 
- Public Member Functions inherited from ImgReaderGdal
 ImgReaderGdal (void)
 default constructor. Image needs to be opened later with one of the open methods.
 
 ImgReaderGdal (const std::string &filename, const GDALAccess &readMode=GA_ReadOnly)
 constructor opening an image. Set memory (in MB) to cache a number of rows in memory
 
 ~ImgReaderGdal (void)
 destructor
 
void open (const std::string &filename, const GDALAccess &readMode=GA_ReadOnly)
 Open an image. More...
 
template<typename T >
void readData (T &value, int col, int row, int band=0)
 Read a single pixel cell value at a specific column and row for a specific band (all indices start counting from 0) More...
 
template<typename T >
void readData (std::vector< T > &buffer, int minCol, int maxCol, int row, int band=0)
 Read pixel cell values for a range of columns for a specific row and band (all indices start counting from 0) More...
 
template<typename T >
void readData (std::vector< T > &buffer, int minCol, int maxCol, double row, int band=0, RESAMPLE resample=NEAR)
 Read pixel cell values for a range of columns for a specific row and band (all indices start counting from 0). The row counter can be floating, in which case a resampling is applied at the row level. You still must apply the resampling at column level. This function will be deprecated, as the GDAL API now supports rasterIO resampling (see http://www.gdal.org/structGDALRasterIOExtraArg.html) More...
 
template<typename T >
void readDataBlock (Vector2d< T > &buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band=0)
 Read pixel cell values for a range of columns and rows for a specific band (all indices start counting from 0). The buffer is a two dimensional vector (stl vector of stl vector) representing [row][col]. More...
 
template<typename T >
void readDataBlock (std::vector< T > &buffer, int minCol, int maxCol, int minRow, int maxRow, int band=0)
 Read pixel cell values for a range of columns and rows for a specific band (all indices start counting from 0). The buffer is a one dimensional stl vector representing all pixel values read starting from upper left to lower right. More...
 
template<typename T >
void readData (std::vector< T > &buffer, int row, int band=0)
 Read pixel cell values for an entire row for a specific band (all indices start counting from 0) More...
 
template<typename T >
void readData (std::vector< T > &buffer, double row, int band=0, RESAMPLE resample=NEAR)
 Read pixel cell values for an entire row for a specific band (all indices start counting from 0). The row counter can be floating, in which case a resampling is applied at the row level. You still must apply the resampling at column level. This function will be deprecated, as the GDAL API now supports rasterIO resampling (see http://www.gdal.org/structGDALRasterIOExtraArg.html) More...
 
void getMinMax (int startCol, int endCol, int startRow, int endRow, int band, double &minValue, double &maxValue)
 Get the minimum and maximum cell values for a specific band in a region of interest defined by startCol, endCol, startRow and endRow (all indices start counting from 0). More...
 
void getMinMax (double &minValue, double &maxValue, int band=0)
 Get the minimum and maximum cell values for a specific band (all indices start counting from 0). More...
 
double getMin (int &col, int &row, int band=0)
 Get the minimum cell values for a specific band and report the column and row in which the minimum value was found (all indices start counting from 0). More...
 
double getMax (int &col, int &row, int band=0)
 Get the maximum cell values for a specific band and report the column and row in which the maximum value was found (all indices start counting from 0). More...
 
double getHistogram (std::vector< double > &histvector, double &min, double &max, unsigned int &nbin, int theBand=0, bool kde=false)
 Calculate the image histogram for a specific band using a defined number of bins and constrained by a minimum and maximum value. A kernel density function can also be applied (default is false). More...
 
void getRefPix (double &refX, double &refY, int band=0)
 Calculate the reference pixel as the centre of gravity pixel (weighted average of all values not taking into account no data values) for a specific band (start counting from 0). More...
 
void getRange (std::vector< short > &range, int Band=0)
 Calculate the range of cell values in the image for a specific band (start counting from 0). More...
 
unsigned long int getNvalid (int band)
 Calculate the number of valid pixels (with a value not defined as no data). More...
 
- Public Member Functions inherited from ImgRasterGdal
 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.
 
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)
 
- Public Member Functions inherited from ImgWriterGdal
 ImgWriterGdal (void)
 default constructor. Image needs to be opened later with one of the open methods.
 
 ImgWriterGdal (const std::string &filename, const ImgReaderGdal &imgSrc, const std::vector< std::string > &options=std::vector< std::string >())
 constructor opening an image for writing, copying image attributes from a source image. Image is directly writen to file.
 
 ImgWriterGdal (const std::string &filename, int ncol, int nrow, int nband, const GDALDataType &dataType, const std::string &imageType, const std::vector< std::string > &options=std::vector< std::string >())
 constructor opening an image for writing, defining all image attributes. Image is directly written to file.
 
 ~ImgWriterGdal (void)
 destructor
 
void open (const std::string &filename, const ImgReaderGdal &imgSrc, const std::vector< std::string > &options=std::vector< std::string >())
 Open an image for writing, copying image attributes from a source image. Image is directly written to file. More...
 
void open (const std::string &filename, int ncol, int nrow, int nband, const GDALDataType &dataType, const std::string &imageType, const std::vector< std::string > &options=std::vector< std::string >())
 Open an image for writing, defining all image attributes. Image is directly written to file. More...
 
void close (void)
 Close the image.
 
void setImageDescription (const std::string &imageDescription)
 Set the image description (only for GeoTiff format: TIFFTAG_IMAGEDESCRIPTION)
 
template<typename T >
bool writeData (T &value, int col, int row, int band=0)
 Write a single pixel cell value at a specific column and row for a specific band (all indices start counting from 0) More...
 
template<typename T >
bool writeData (std::vector< T > &buffer, int minCol, int maxCol, int row, int band=0)
 Write pixel cell values for a range of columns for a specific row and band (all indices start counting from 0) More...
 
template<typename T >
bool writeData (std::vector< T > &buffer, int row, int band=0)
 Write pixel cell values for an entire row for a specific band (all indices start counting from 0) More...
 
template<typename T >
bool writeDataBlock (Vector2d< T > &buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band=0)
 Write pixel cell values for a range of columns and rows for a specific band (all indices start counting from 0). The buffer is a two dimensional vector (stl vector of stl vector) representing [row][col]. More...
 
void setColorTable (const std::string &filename, int band=0)
 Set the color table using an (ASCII) file with 5 columns (value R G B alpha) More...
 
void setColorTable (GDALColorTable *colorTable, int band=0)
 Set the color table using the GDAL class GDALColorTable. More...
 
void setMetadata (char **metadata)
 Set specific metadata (driver specific) More...
 
void rasterizeOgr (ImgReaderOgr &ogrReader, const std::vector< double > &burnValues, const std::vector< std::string > &controlOptions=std::vector< std::string >(), const std::vector< std::string > &layernames=std::vector< std::string >())
 Rasterize an OGR vector dataset using the gdal algorithm "GDALRasterizeLayers". More...
 
void rasterizeBuf (ImgReaderOgr &ogrReader, const std::vector< double > &burnValues, const std::vector< std::string > &controlOptions=std::vector< std::string >(), const std::vector< std::string > &layernames=std::vector< std::string >())
 Rasterize an OGR vector dataset in memory using the gdal algorithm "GDALRasterizeLayersBuf".
 

Protected Member Functions

void setCodec ()
 
- Protected Member Functions inherited from ImgReaderGdal
void setCodec (const GDALAccess &readMode=GA_ReadOnly)
 Set GDAL dataset number of columns, rows, bands and geotransform. More...
 
- Protected Member Functions inherited from ImgWriterGdal
virtual void setCodec (const std::string &imageType)
 Register GDAL driver, setting the datatype, imagetype and some metadata. More...
 
virtual void setCodec (const ImgReaderGdal &ImgSrc)
 Register GDAL driver, setting the datatype, imagetype and some metadata. More...
 

Protected Attributes

std::string m_filename
 
GDALDataset * m_gds
 
int m_ncol
 
int m_nrow
 
int m_nband
 
double m_gt [6]
 
std::vector< double > m_noDataValues
 
std::vector< double > m_scale
 
std::vector< double > m_offset
 
- Protected Attributes inherited from ImgRasterGdal
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)
 
- Protected Attributes inherited from ImgWriterGdal
std::vector< std::string > m_options
 

Detailed Description

Definition at line 27 of file ImgGdal.h.

Constructor & Destructor Documentation

ImgUpdaterGdal::ImgUpdaterGdal ( const std::string &  filename,
const GDALAccess &  readMode = GA_Update 
)

constructor opening an image in update mode (read and write).

Parameters
filenameOpen a raster dataset with this filename
readModeOpen dataset in ReadOnly or Update mode

Definition at line 29 of file ImgUpdaterGdal.cc.

29  {
30  open(filename,readMode);
31 }

Member Function Documentation

void ImgUpdaterGdal::open ( const std::string &  filename,
const GDALAccess &  readMode = GA_Update 
)

Open an image in update mode (read and write).

Parameters
filenameOpen a raster dataset with this filename
readModeOpen dataset in ReadOnly or Update mode

Definition at line 46 of file ImgUpdaterGdal.cc.

47 {
48  ImgReaderGdal::open(filename,readMode);
49 }
void open(const std::string &filename, const GDALAccess &readMode=GA_ReadOnly)
Open an image.

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