isce3 0.25.0
Loading...
Searching...
No Matches
Raster Class Reference

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.
 
 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.
 
 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.
 
template<typename T>
 Raster (Eigen::PlainObjectBase< T > &view)
 
template<typename Derived>
 Raster (Eigen::Block< Derived > &view)
 
 Raster (const std::string &fname, const Raster &rast)
 Create new raster object like another.
 
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.
 
 Raster (isce3::io::gdal::Raster &)
 Create legacy raster reference to isce3::io::gdal::Raster.
 
 Raster (const Raster &)
 Copy constructor.
 
 Raster (GDALDataset *inputDataset, bool owner=true)
 Constructor from an existing GDAL Dataset.
 
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.
 
Rasteroperator= (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.
 
bool dataset_owner () const
 GDALDataset owner getter.
 
GDALDataType dtype (const size_t band=1) const
 Return GDALDatatype of specified band.
 
bool match (const Raster &rast) const
 Check dimensions compatibility with another raster.
 
void open (const std::string &fname, GDALAccess access)
 Open file with GDAL.
 
void addRasterToVRT (const isce3::io::Raster &rast)
 Add a raster to VRT.
 
void addBandToVRT (GDALRasterBand *inBand)
 Add a GDALRasterBand to VRT.
 
void addRawBandToVRT (const std::string &fname, GDALDataType dtype)
 Add a raw data band to VRT.
 
template<typename T>
void getSetValue (T &buffer, size_t xidz, size_t yidx, size_t band, GDALRWFlag)
 Get/Set single value for given band.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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 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 getBlock (isce3::core::EArray2D< T > &mat, size_t xidx, size_t yidx, size_t band=1)
 Read/write block of data from given band to/from EArray2D<T>
 
template<typename T>
void getBlock (isce3::core::EMatrix2D< T > &mat, size_t xidx, size_t yidx, size_t band=1)
 Read/write block of data from given band to/from EArray2D<T>
 
template<typename Derived>
void getBlock (Eigen::Block< Derived > &block, int xoff, int yoff, int band=1) const
 
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.
 
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 setBlock (isce3::core::Matrix< T > &mat, size_t xidx, size_t yidx, size_t band=1)
 
template<typename T>
void setBlock (isce3::core::EArray2D< T > &mat, size_t xidx, size_t yidx, size_t band=1)
 
template<typename T>
void setBlock (isce3::core::EMatrix2D< T > &mat, size_t xidx, size_t yidx, size_t band=1)
 
template<typename Derived>
void setBlock (const Eigen::Block< Derived > &block, int xoff, int yoff, int band=1)
 
int getEPSG () const
 Return EPSG code corresponding to raster.
 
int setEPSG (int code)
 Set EPSG code.
 
void setGeoTransform (double *arr)
 Set Raster GeoTransform from buffer, vector, or valarray.
 
void setGeoTransform (std::vector< double > &)
 
void setGeoTransform (std::valarray< double > &)
 
void getGeoTransform (double *) const
 Copy Raster GeoTransform into a buffer, vector, or valarray.
 
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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Raster() [1/7]

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.

Parameters
[in]fnameExisting filename
[in]accessGDAL access mode

Files are opened with GDALOpenShared

◆ Raster() [2/7]

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.

Parameters
[in]fnameFilename to create
[in]widthWidth of raster image
[in]lengthLength of raster image
[in]numBandsNumber of bands in raster image
[in]dtypeGDALDataType associated with dataset
[in]driverNameGDAL 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

◆ Raster() [3/7]

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.

Parameters
[in]fnameFile name to create
[in]widthWidth of raster image
[in]lengthLength of raster image
[in]dtypeGDALDataType associated with dataset

◆ Raster() [4/7]

isce3::io::Raster::Raster ( const std::string & fname,
const Raster & rast )

Create new raster object like another.

Parameters
[in]fnameFile name to create
[in]rastReference raster object

◆ Raster() [5/7]

isce3::io::Raster::Raster ( const std::string & fname,
const std::vector< Raster > & rastVec )

Create a VRT raster dataset with collection of bands from Rasters.

Parameters
[in]fnameOutput VRT filename to create
[in]rastVecstd::vector of Raster objects

◆ Raster() [6/7]

isce3::io::Raster::Raster ( const Raster & rast)

Copy constructor.

Parameters
[in]rastSource raster.

It increments GDAL's reference counter after weak-copying the pointer

◆ Raster() [7/7]

isce3::io::Raster::Raster ( GDALDataset * inputDataset,
bool owner = true )

Constructor from an existing GDAL Dataset.

Parameters
[in]inputDatasetPointer to an existing dataset

Member Function Documentation

◆ addBandToVRT()

void isce3::io::Raster::addBandToVRT ( GDALRasterBand * inBand)
inline

Add a GDALRasterBand to VRT.

Parameters
[in]inBandGDALRasterBand pointer

◆ addRasterToVRT()

void isce3::io::Raster::addRasterToVRT ( const isce3::io::Raster & rast)
inline

Add a raster to VRT.

Parameters
[in]rastInput raster dataset

◆ addRawBandToVRT()

void isce3::io::Raster::addRawBandToVRT ( const std::string & fname,
GDALDataType dtype )
inline

Add a raw data band to VRT.

Parameters
[in]fnameRaw file name
[in]dtypeGDALDataType

◆ dataset()

void isce3::io::Raster::dataset ( GDALDataset * ds)
inline

GDALDataset pointer setter.

Parameters
[in]dsGDALDataset pointer

◆ dtype()

GDALDataType isce3::io::Raster::dtype ( const size_t band = 1) const
inline

Return GDALDatatype of specified band.

Parameters
[in]bandBand number in 1-index

◆ getBlock()

template<typename T>
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.

Parameters
[in]bufferRaw pointer to buffer
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]iowidthNumber of pixels to read
[in]iolengthNumber of lines to read
[in]bandBand index (1-based)

◆ getEPSG()

int isce3::io::Raster::getEPSG ( ) const

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+

◆ getGeoTransform() [1/3]

void isce3::io::Raster::getGeoTransform ( double * arr) const
inline

Copy Raster GeoTransform into a buffer, vector, or valarray.

Parameters
[in]arrpointer to buffer of 6 double precision numbers

No memory check is performed

◆ getGeoTransform() [2/3]

void isce3::io::Raster::getGeoTransform ( std::valarray< double > & arr) const
inline
Parameters
[in]arrstd::valarray to copy GeoTransform into

◆ getGeoTransform() [3/3]

void isce3::io::Raster::getGeoTransform ( std::vector< double > & arr) const
inline
Parameters
[in]arrstd::vector to copy GeoTransform into

◆ getLine()

template<typename T>
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.

Parameters
[in]bufferRaw pointer to buffer
[in]yidxLine index (0-based)
[in]iowidthNumber of samples to read
[in]bandBand index (1-based)

◆ getSetBlock()

template<typename T>
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.

Parameters
[in]bufferRaw pointer for I/O
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]iowidthNumber of pixels to read/write
[in]iolengthNumber of lines to read/write

Datatype translation is automatically determined from the type of buffer

◆ getSetLine()

template<typename T>
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.

Parameters
[in,out]bufferRaw pointer to buffer
[in]xidxLine location within band (0-based)
[in]iowidthWidth of I/O buffer
[in]bandBand index (1-based)
[in]iodirGDALRWFlag to indicate read / write

Datatype translation is automatically determined using type of pointer passed

◆ getSetValue()

template<typename T>
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.

Parameters
[in,out]bufferBuffer of type T
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]bandBand index (1-based)
[in]GDALRWFlag

Determines datatype translation to use from the type of buffer passed in

◆ getValue()

template<typename T>
void isce3::io::Raster::getValue ( T & buffer,
size_t xidx,
size_t yidx,
size_t band = 1 )
Parameters
[out]bufferBuffer to copy data into
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]bandBand index (1-based)

◆ match()

bool isce3::io::Raster::match ( const Raster & rast) const
inline

Check dimensions compatibility with another raster.

Parameters
[in]rastReference raster to compare against

◆ open()

void isce3::io::Raster::open ( const std::string & fname,
GDALAccess access = GA_ReadOnly )
inline

Open file with GDAL.

Parameters
[in]fnameFilename to open
[in]accessAccess mode

◆ setBlock()

template<typename T>
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.

Parameters
[in]bufferRaw pointer to buffer
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]iowidthNumber of pixels to read
[in]iolengthNumber of lines to read
[in]bandBand index (1-based)

◆ setEPSG()

int isce3::io::Raster::setEPSG ( int epsgcode)

Set EPSG code.

Parameters
[in]epsgcodeEPSG code corresponding to projection system

GDAL relies on GDAL_DATA environment variable to interpret these codes. Make sure that these are set.

◆ setGeoTransform() [1/3]

void isce3::io::Raster::setGeoTransform ( double * arr)
inline

Set Raster GeoTransform from buffer, vector, or valarray.

Parameters
[in]arrArray of 6 double precision numbers

No memory check performed for length of array

◆ setGeoTransform() [2/3]

void isce3::io::Raster::setGeoTransform ( std::valarray< double > & arr)
inline
Parameters
[in]arrstd::valarray of 6 double precision numbers

◆ setGeoTransform() [3/3]

void isce3::io::Raster::setGeoTransform ( std::vector< double > & arr)
inline
Parameters
[in]arrstd::vector of 6 double precision numbers

◆ setLine()

template<typename T>
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.

Parameters
[in]bufferRaw pointer to buffer
[in]yidxLine index (0-based)
[in]iowidthNumber of samples to write
[in]bandBand index (1-based)

◆ setValue()

template<typename T>
void isce3::io::Raster::setValue ( T & buffer,
size_t xidx,
size_t yidx,
size_t band = 1 )
Parameters
[in]bufferBuffer to copy data from
[in]xidxPixel index (0-based)
[in]yidxLine index (0-based)
[in]bandBand index (1-based)

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

Generated for ISCE3.0 by doxygen 1.13.2.