Data structure meant to handle Raster I/O operations. More...
#include <Raster.h>
Public Member Functions | |
Raster (const std::string &fname, GDALAccess access=GA_ReadOnly) | |
Constructor to open an existing file with specified Access mode - defaults to read-only. More... | |
Raster (const std::string &fname, size_t width, size_t length, size_t numBands, GDALDataType dtype=isce3::io::defaultGDALDataType, const std::string &driverName=isce3::io::defaultGDALDriver) | |
Constructor to create a dataset. More... | |
Raster (const std::string &fname, size_t width, size_t length, GDALDataType dtype=isce3::io::defaultGDALDataType) | |
Constructor to create a 1 band dataset with default Driver. More... | |
template<typename T > | |
Raster (isce3::core::Matrix< T > &matrix) | |
Constructor for a 1 band dataset from isce3::core::Matrix<T> | |
template<typename T > | |
Raster (pyre::grid::View< T > &view) | |
Raster (const std::string &fname, const Raster &rast) | |
Create new raster object like another. More... | |
template<typename T > | |
Raster (const std::string &fname, const std::vector< T > &buffer, size_t length) | |
template<typename T > | |
Raster (const std::string &fname, const std::valarray< T > &buffer, size_t length) | |
Raster (const std::string &fname, const std::vector< Raster > &rastVec) | |
Create a VRT raster dataset with collection of bands from Rasters. More... | |
Raster (isce3::io::gdal::Raster &) | |
Create legacy raster reference to isce3::io::gdal::Raster. | |
Raster (const Raster &) | |
Copy constructor. More... | |
Raster (GDALDataset *inputDataset, bool owner=true) | |
Constructor from an existing GDAL Dataset. More... | |
void | initFromPointer (void *ptr, GDALDataType dtype, size_t width, size_t length, size_t pixeloffset, size_t lineoffset) |
Construct dataset for a 1 band dataset with raw pointer, dimensions and offsets. | |
~Raster () | |
Destructor. | |
Raster & | operator= (const Raster &) |
Assignment operator. | |
size_t | length () const |
Length getter. | |
size_t | width () const |
Width getter. | |
size_t | numBands () const |
Number of bands getter. | |
GDALAccess | access () const |
Access mode getter. | |
GDALDataset * | dataset () const |
GDALDataset pointer getter. | |
void | dataset (GDALDataset *ds) |
GDALDataset pointer setter. More... | |
GDALDataType | dtype (const size_t band=1) const |
Return GDALDatatype of specified band. More... | |
bool | match (const Raster &rast) const |
Check dimensions compatibility with another raster. More... | |
void | open (const std::string &fname, GDALAccess access) |
Open file with GDAL. More... | |
void | addRasterToVRT (const isce3::io::Raster &rast) |
Add a raster to VRT. More... | |
void | addBandToVRT (GDALRasterBand *inBand) |
Add a GDALRasterBand to VRT. More... | |
void | addRawBandToVRT (const std::string &fname, GDALDataType dtype) |
Add a raw data band to VRT. More... | |
template<typename T > | |
void | getSetValue (T &buffer, size_t xidz, size_t yidx, size_t band, GDALRWFlag) |
Get/Set single value for given band. More... | |
template<typename T > | |
void | getValue (T &buffer, size_t xidx, size_t yidx, size_t band=1) |
template<typename T > | |
void | setValue (T &buffer, size_t xidx, size_t yidx, size_t band=1) |
template<typename T > | |
void | getSetLine (T *buffer, size_t yidx, size_t iowidth, size_t band, GDALRWFlag iodir) |
Get/Set line in a band from raw pointer. More... | |
template<typename T > | |
void | getLine (T *buffer, size_t yidx, size_t iowidth, size_t band=1) |
Read one line of data from given band to buffer, vector, or valarray. More... | |
template<typename T > | |
void | getLine (std::vector< T > &vec, size_t yidx, size_t band=1) |
template<typename T > | |
void | getLine (std::valarray< T > &arr, size_t yidx, size_t band=1) |
template<typename T > | |
void | setLine (T *buffer, size_t yidx, size_t iowidth, size_t band=1) |
Write one line of data from buffer, vector, or valarray to given band. More... | |
template<typename T > | |
void | setLine (std::vector< T > &vec, size_t yidx, size_t band=1) |
template<typename T > | |
void | setLine (std::valarray< T > &arr, size_t yidx, size_t band=1) |
template<typename T > | |
void | getSetBlock (T *buffer, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band, GDALRWFlag iodir) |
Get/Set block in band from raw pointer. More... | |
template<typename T > | |
void | getBlock (T *buffer, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
Read block of data from given band to buffer, vector, or valarray. More... | |
template<typename T > | |
void | getBlock (std::vector< T > &vec, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
template<typename T > | |
void | getBlock (std::valarray< T > &arr, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
template<typename T > | |
void | setBlock (T *buffer, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
Write block of data to given band from buffer, vector, or valarray. More... | |
template<typename T > | |
void | setBlock (std::vector< T > &vec, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
template<typename T > | |
void | setBlock (std::valarray< T > &arr, size_t xidx, size_t yidx, size_t iowidth, size_t iolength, size_t band=1) |
template<typename T > | |
void | getBlock (isce3::core::Matrix< T > &mat, size_t xidx, size_t yidx, size_t band=1) |
Read/write block of data from given band to/from Matrix<T> | |
template<typename T > | |
void | setBlock (isce3::core::Matrix< T > &mat, size_t xidx, size_t yidx, size_t band=1) |
template<typename T > | |
void | getSetBlock (pyre::grid::View< T > &view, size_t xidx, size_t yidx, size_t band, GDALRWFlag iodir) |
Read/Write block of data from given band to/from Matrix<T>::view_type. | |
template<typename T > | |
void | getBlock (pyre::grid::View< T > &view, size_t xidx, size_t yidx, size_t band=1) |
template<typename T > | |
void | setBlock (pyre::grid::View< T > &view, size_t xidx, size_t yidx, size_t band=1) |
int | getEPSG () |
Return EPSG code corresponding to raster. More... | |
int | setEPSG (int code) |
Set EPSG code. More... | |
void | setGeoTransform (double *arr) |
Set Raster GeoTransform from buffer, vector, or valarray. More... | |
void | setGeoTransform (std::vector< double > &) |
void | setGeoTransform (std::valarray< double > &) |
void | getGeoTransform (double *) const |
Copy Raster GeoTransform into a buffer, vector, or valarray. More... | |
void | getGeoTransform (std::vector< double > &) const |
void | getGeoTransform (std::valarray< double > &) const |
double | x0 () const |
Return Western Limit of Raster. | |
double | y0 () const |
Return Northern Limit of Raster. | |
double | dx () const |
Return EW pixel spacing of Raster. | |
double | dy () const |
Return NS pixel spacing of Raster. | |
Data structure meant to handle Raster I/O operations.
This is currently a thin wrapper over GDAL's Dataset class with some simpler interfaces for I/O. ISCE is expected to only support North-up and West-left oriented rasters.
isce3::io::Raster::Raster | ( | const std::string & | fname, |
GDALAccess | access = GA_ReadOnly |
||
) |
Constructor to open an existing file with specified Access mode - defaults to read-only.
[in] | fname | Existing filename |
[in] | access | GDAL access mode |
Files are opened with GDALOpenShared
isce3::io::Raster::Raster | ( | const std::string & | fname, |
size_t | width, | ||
size_t | length, | ||
size_t | numBands, | ||
GDALDataType | dtype = isce3::io::defaultGDALDataType , |
||
const std::string & | driverName = isce3::io::defaultGDALDriver |
||
) |
Constructor to create a dataset.
[in] | fname | Filename to create |
[in] | width | Width of raster image |
[in] | length | Length of raster image |
[in] | numBands | Number of bands in raster image |
[in] | dtype | GDALDataType associated with dataset |
[in] | driverName | GDAL Driver to use |
In general, GDAL is used to create dataset. When VRT driver is used, the dataset is interpreted in a special manner - it is assumed that the user expects a flat binary file with a VRT pointing to the data using VRTRawRasterBand
isce3::io::Raster::Raster | ( | const std::string & | fname, |
size_t | width, | ||
size_t | length, | ||
GDALDataType | dtype = isce3::io::defaultGDALDataType |
||
) |
Constructor to create a 1 band dataset with default Driver.
[in] | fname | File name to create |
[in] | width | Width of raster image |
[in] | length | Length of raster image |
[in] | dtype | GDALDataType associated with dataset |
isce3::io::Raster::Raster | ( | const std::string & | fname, |
const Raster & | rast | ||
) |
Create new raster object like another.
[in] | fname | File name to create |
[in] | rast | Reference raster object |
isce3::io::Raster::Raster | ( | const std::string & | fname, |
const std::vector< Raster > & | rastVec | ||
) |
Create a VRT raster dataset with collection of bands from Rasters.
[in] | fname | Output VRT filename to create |
[in] | rastVec | std::vector of Raster objects |
isce3::io::Raster::Raster | ( | const Raster & | rast | ) |
Copy constructor.
[in] | rast | Source raster. |
It increments GDAL's reference counter after weak-copying the pointer
isce3::io::Raster::Raster | ( | GDALDataset * | inputDataset, |
bool | owner = true |
||
) |
Constructor from an existing GDAL Dataset.
[in] | inputDataset | Pointer to an existing dataset |
|
inline |
Add a GDALRasterBand to VRT.
[in] | inBand | GDALRasterBand pointer |
|
inline |
Add a raster to VRT.
[in] | rast | Input raster dataset |
|
inline |
Add a raw data band to VRT.
[in] | fname | Raw file name |
[in] | dtype | GDALDataType |
|
inline |
GDALDataset pointer setter.
[in] | ds | GDALDataset pointer |
|
inline |
Return GDALDatatype of specified band.
[in] | band | Band number in 1-index |
void isce3::io::Raster::getBlock | ( | T * | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | iolength, | ||
size_t | band = 1 |
||
) |
Read block of data from given band to buffer, vector, or valarray.
[in] | buffer | Raw pointer to buffer |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | iowidth | Number of pixels to read |
[in] | iolength | Number of lines to read |
[in] | band | Band index (1-based) |
int isce3::io::Raster::getEPSG | ( | ) |
Return EPSG code corresponding to raster.
Uses GDAL's inbuilt OSRFindMatches to determine the EPSG code from the WKT representation of the projection system.
This is designed to work with GDAL 2.3+
|
inline |
Copy Raster GeoTransform into a buffer, vector, or valarray.
[in] | arr | pointer to buffer of 6 double precision numbers |
No memory check is performed
|
inline |
[in] | arr | std::vector to copy GeoTransform into |
|
inline |
[in] | arr | std::valarray to copy GeoTransform into |
void isce3::io::Raster::getLine | ( | T * | buffer, |
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | band = 1 |
||
) |
Read one line of data from given band to buffer, vector, or valarray.
[in] | buffer | Raw pointer to buffer |
[in] | yidx | Line index (0-based) |
[in] | iowidth | Number of samples to read |
[in] | band | Band index (1-based) |
void isce3::io::Raster::getSetBlock | ( | T * | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | iolength, | ||
size_t | band, | ||
GDALRWFlag | iodir | ||
) |
Get/Set block in band from raw pointer.
[in] | buffer | Raw pointer for I/O |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | iowidth | Number of pixels to read/write |
[in] | iolength | Number of lines to read/write |
Datatype translation is automatically determined from the type of buffer
void isce3::io::Raster::getSetLine | ( | T * | buffer, |
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | band, | ||
GDALRWFlag | iodir | ||
) |
Get/Set line in a band from raw pointer.
[in,out] | buffer | Raw pointer to buffer |
[in] | xidx | Line location within band (0-based) |
[in] | iowidth | Width of I/O buffer |
[in] | band | Band index (1-based) |
[in] | iodir | GDALRWFlag to indicate read / write |
Datatype translation is automatically determined using type of pointer passed
void isce3::io::Raster::getSetValue | ( | T & | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | band, | ||
GDALRWFlag | iodir | ||
) |
Get/Set single value for given band.
[in,out] | buffer | Buffer of type T |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | band | Band index (1-based) |
[in] | GDALRWFlag | Determines datatype translation to use from the type of buffer passed in |
void isce3::io::Raster::getValue | ( | T & | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | band = 1 |
||
) |
[out] | buffer | Buffer to copy data into |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | band | Band index (1-based) |
|
inline |
Check dimensions compatibility with another raster.
[in] | rast | Reference raster to compare against |
|
inline |
Open file with GDAL.
[in] | fname | Filename to open |
[in] | access | Access mode |
void isce3::io::Raster::setBlock | ( | T * | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | iolength, | ||
size_t | band = 1 |
||
) |
Write block of data to given band from buffer, vector, or valarray.
[in] | buffer | Raw pointer to buffer |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | iowidth | Number of pixels to read |
[in] | iolength | Number of lines to read |
[in] | band | Band index (1-based) |
int isce3::io::Raster::setEPSG | ( | int | epsgcode | ) |
Set EPSG code.
[in] | epsgcode | EPSG code corresponding to projection system |
GDAL relies on GDAL_DATA environment variable to interpret these codes. Make sure that these are set.
|
inline |
Set Raster GeoTransform from buffer, vector, or valarray.
[in] | arr | Array of 6 double precision numbers |
No memory check performed for length of array
|
inline |
[in] | arr | std::vector of 6 double precision numbers |
|
inline |
[in] | arr | std::valarray of 6 double precision numbers |
void isce3::io::Raster::setLine | ( | T * | buffer, |
size_t | yidx, | ||
size_t | iowidth, | ||
size_t | band = 1 |
||
) |
Write one line of data from buffer, vector, or valarray to given band.
[in] | buffer | Raw pointer to buffer |
[in] | yidx | Line index (0-based) |
[in] | iowidth | Number of samples to write |
[in] | band | Band index (1-based) |
void isce3::io::Raster::setValue | ( | T & | buffer, |
size_t | xidx, | ||
size_t | yidx, | ||
size_t | band = 1 |
||
) |
[in] | buffer | Buffer to copy data from |
[in] | xidx | Pixel index (0-based) |
[in] | yidx | Line index (0-based) |
[in] | band | Band index (1-based) |