isce3 0.25.0
Loading...
Searching...
No Matches
isce3::io::gdal::Raster Class Reference

Wrapper for GDALRasterBand representing a single raster. More...

#include <Raster.h>

Public Member Functions

 Raster (const std::string &path, GDALAccess access=GA_ReadOnly)
 Open an existing file containing a single raster band as a GDAL raster.
 
 Raster (const isce3::io::IDataSet &dataset, GDALAccess access=GA_ReadOnly)
 Open an HDF5 dataset containing a single raster band as a GDAL raster.
 
 Raster (const std::string &path, int band, GDALAccess access=GA_ReadOnly)
 Open an existing file as a GDAL dataset and fetch the specified raster band.
 
 Raster (const isce3::io::IDataSet &dataset, int band, GDALAccess access=GA_ReadOnly)
 Open an HDF5 dataset as a GDAL dataset and fetch the specified raster band.
 
 Raster (const std::string &path, int width, int length, GDALDataType datatype, const std::string &driver=defaultDriver())
 Create a new GDAL dataset containing a single raster band.
 
template<typename T>
 Raster (const T *data, int width, int length)
 Create a read-only raster describing an existing in-memory array.
 
template<typename T>
 Raster (T *data, int width, int length, GDALAccess access=GA_Update)
 Create a raster describing an existing in-memory array.
 
template<typename T>
 Raster (const T *data, int width, int length, std::size_t colstride, std::size_t rowstride)
 Create a read-only raster describing an existing in-memory array.
 
template<typename T>
 Raster (T *data, int width, int length, std::size_t colstride, std::size_t rowstride, GDALAccess access=GA_Update)
 Create a raster describing an existing in-memory array.
 
const Datasetdataset () const
 Get the dataset containing the raster.
 
Datasetdataset ()
 Get the dataset containing the raster.
 
int band () const
 Band index (1-based)
 
GDALDataType datatype () const
 Datatype identifier.
 
GDALAccess access () const
 Access mode.
 
int width () const
 Number of columns.
 
int length () const
 Number of rows.
 
std::string driver () const
 Driver name.
 
GeoTransform getGeoTransform () const
 Get transform from raster coordinates (pixel, line) to projected coordinates (x, y)
 
void setGeoTransform (const GeoTransform &transform)
 Set geotransform.
 
isce3::core::ProjectionBasegetProjection () const
 Get spatial reference system.
 
void setProjection (const isce3::core::ProjectionBase *proj)
 Set spatial reference system.
 
double x0 () const
 Left edge of left-most pixel in projection coordinates.
 
double y0 () const
 Upper edge of upper-most line in projection coordinates.
 
double dx () const
 Pixel width in projection coordinates.
 
double dy () const
 Line height in projection coordinates.
 
template<typename T>
void readPixel (T *dst, int col, int row) const
 Read a single pixel value from the raster.
 
template<typename T>
void writePixel (const T *src, int col, int row)
 Write a single pixel value to the raster.
 
template<typename T>
void readLine (T *dst, int row) const
 Read a line of pixel data from the raster.
 
template<typename T>
void writeLine (const T *src, int row)
 Write a line of pixel data to the raster.
 
template<typename T>
void readLines (T *dst, int first_row, int num_rows) const
 Read one or more lines of pixel data from the raster.
 
template<typename T>
void writeLines (const T *src, int first_row, int num_rows)
 Write one or more lines of pixel data to the raster.
 
template<typename T>
void readBlock (T *dst, int first_col, int first_row, int num_cols, int num_rows) const
 Read a block of pixel data from the raster.
 
template<typename T>
void writeBlock (const T *src, int first_col, int first_row, int num_cols, int num_rows)
 Write a block of pixel data to the raster.
 
template<typename T>
void readAll (T *dst) const
 Read all pixel data from the raster.
 
template<typename T>
void writeAll (const T *src)
 Write all pixel data to the raster.
 
GDALRasterBand * get ()
 Get the underlying GDALRasterBand pointer.
 
const GDALRasterBand * get () const
 Get the underlying GDALRasterBand pointer.
 
Buffer memmap ()
 Create a virtual memory mapping of the raster.
 
template<typename T>
TypedBuffer< T > memmap ()
 Create a virtual memory mapping of the raster.
 
template<typename Derived>
 Raster (Eigen::PlainObjectBase< Derived > &view)
 

Static Public Member Functions

static std::string defaultDriver ()
 Default GDAL driver for raster creation.
 

Friends

class Dataset
 

Detailed Description

Wrapper for GDALRasterBand representing a single raster.

Constructor & Destructor Documentation

◆ Raster() [1/9]

isce3::io::gdal::Raster::Raster ( const std::string & path,
GDALAccess access = GA_ReadOnly )
inline

Open an existing file containing a single raster band as a GDAL raster.

Parameters
[in]pathFile path
[in]accessAccess mode

◆ Raster() [2/9]

isce3::io::gdal::Raster::Raster ( const isce3::io::IDataSet & dataset,
GDALAccess access = GA_ReadOnly )
inline

Open an HDF5 dataset containing a single raster band as a GDAL raster.

The resulting raster is invalidated if the HDF5 file is closed.

Parameters
[in]datasetHDF5 dataset
[in]accessAccess mode

◆ Raster() [3/9]

isce3::io::gdal::Raster::Raster ( const std::string & path,
int band,
GDALAccess access = GA_ReadOnly )
inline

Open an existing file as a GDAL dataset and fetch the specified raster band.

Parameters
[in]pathFile path
[in]bandRaster band index (1-based)
[in]accessAccess mode

◆ Raster() [4/9]

isce3::io::gdal::Raster::Raster ( const isce3::io::IDataSet & dataset,
int band,
GDALAccess access = GA_ReadOnly )
inline

Open an HDF5 dataset as a GDAL dataset and fetch the specified raster band.

The resulting raster is invalidated if the HDF5 file is closed.

Parameters
[in]datasetHDF5 dataset
[in]bandRaster band index (1-based)
[in]accessAccess mode

◆ Raster() [5/9]

isce3::io::gdal::Raster::Raster ( const std::string & path,
int width,
int length,
GDALDataType datatype,
const std::string & driver = defaultDriver() )
inline

Create a new GDAL dataset containing a single raster band.

Parameters
[in]pathFile path
[in]widthNumber of columns
[in]lengthNumber of rows
[in]datatypeData type identifier
[in]driverGDAL driver name

◆ Raster() [6/9]

template<typename T>
isce3::io::gdal::Raster::Raster ( const T * data,
int width,
int length )
inline

Create a read-only raster describing an existing in-memory array.

The data layout is assumed to be in row major format.

Parameters
[in]dataPointer to first pixel
[in]widthNumber of columns
[in]lengthNumber of rows

◆ Raster() [7/9]

template<typename T>
isce3::io::gdal::Raster::Raster ( T * data,
int width,
int length,
GDALAccess access = GA_Update )
inline

Create a raster describing an existing in-memory array.

The data layout is assumed to be in row major format.

Parameters
[in]dataPointer to first pixel
[in]widthNumber of columns
[in]lengthNumber of rows
[in]accessAccess mode

◆ Raster() [8/9]

template<typename T>
isce3::io::gdal::Raster::Raster ( const T * data,
int width,
int length,
std::size_t colstride,
std::size_t rowstride )
inline

Create a read-only raster describing an existing in-memory array.

Parameters
[in]dataPointer to first pixel
[in]widthNumber of columns
[in]lengthNumber of rows
[in]colstrideStride in bytes between the start of adjacent columns
[in]rowstrideStride in bytes between the start of adjacent rows

◆ Raster() [9/9]

template<typename T>
isce3::io::gdal::Raster::Raster ( T * data,
int width,
int length,
std::size_t colstride,
std::size_t rowstride,
GDALAccess access = GA_Update )
inline

Create a raster describing an existing in-memory array.

Parameters
[in]dataPointer to first pixel
[in]widthNumber of columns
[in]lengthNumber of rows
[in]colstrideStride in bytes between the start of adjacent columns
[in]rowstrideStride in bytes between the start of adjacent rows
[in]accessAccess mode

Member Function Documentation

◆ getGeoTransform()

GeoTransform isce3::io::gdal::Raster::getGeoTransform ( ) const
inline

Get transform from raster coordinates (pixel, line) to projected coordinates (x, y)

If no transform is found, the default (identity) transform is used.

◆ getProjection()

isce3::core::ProjectionBase * isce3::io::gdal::Raster::getProjection ( ) const
inline

Get spatial reference system.

Exceptions
isce3::except::GDALErrorif the spatial reference system is unavailable

◆ memmap() [1/2]

Buffer isce3::io::gdal::Raster::memmap ( )
inline

Create a virtual memory mapping of the raster.

The memory map is internally managed and is valid only during the lifetime of the raster object.

Returns
A buffer object describing the virtual memory mapping

◆ memmap() [2/2]

template<typename T>
TypedBuffer< T > isce3::io::gdal::Raster::memmap ( )
inline

Create a virtual memory mapping of the raster.

The memory map is internally managed and is valid only during the lifetime of the raster object.

Exceptions
isce3::except::RuntimeErrorif the requested type does not match the underlying raster datatype
Returns
A buffer object describing the virtual memory mapping

◆ readAll()

template<typename T>
void isce3::io::gdal::Raster::readAll ( T * dst) const
inline

Read all pixel data from the raster.

The data will be converted to the requested type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[out]dstDestination buffer

◆ readBlock()

template<typename T>
void isce3::io::gdal::Raster::readBlock ( T * dst,
int first_col,
int first_row,
int num_cols,
int num_rows ) const
inline

Read a block of pixel data from the raster.

The data will be converted to the requested type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[out]dstDestination buffer
[in]first_colIndex of first column
[in]first_rowIndex of first row
[in]num_colsNumber of columns
[in]num_rowsNumber of rows

◆ readLine()

template<typename T>
void isce3::io::gdal::Raster::readLine ( T * dst,
int row ) const
inline

Read a line of pixel data from the raster.

The data will be converted to the requested type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[out]dstDestination buffer
[in]rowRow index

◆ readLines()

template<typename T>
void isce3::io::gdal::Raster::readLines ( T * dst,
int first_row,
int num_rows ) const
inline

Read one or more lines of pixel data from the raster.

The data will be converted to the requested type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[out]dstDestination buffer
[in]first_rowIndex of first row
[in]num_rowsNumber of rows

◆ readPixel()

template<typename T>
void isce3::io::gdal::Raster::readPixel ( T * dst,
int col,
int row ) const
inline

Read a single pixel value from the raster.

The data will be converted to the requested type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[out]dstDestination buffer
[in]colColumn index
[in]rowRow index

◆ setGeoTransform()

void isce3::io::gdal::Raster::setGeoTransform ( const GeoTransform & transform)
inline

Set geotransform.

Exceptions
isce3::except::GDALErrorif the format does not support this operation

◆ setProjection()

void isce3::io::gdal::Raster::setProjection ( const isce3::core::ProjectionBase * proj)
inline

Set spatial reference system.

Exceptions
isce3::except::GDALErrorif the format does not support this operation

◆ writeAll()

template<typename T>
void isce3::io::gdal::Raster::writeAll ( const T * src)
inline

Write all pixel data to the raster.

The data will be converted from the input type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[in]srcSource values

◆ writeBlock()

template<typename T>
void isce3::io::gdal::Raster::writeBlock ( const T * src,
int first_col,
int first_row,
int num_cols,
int num_rows )
inline

Write a block of pixel data to the raster.

The data will be converted from the input type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[in]srcSource values
[in]first_colIndex of first column
[in]first_rowIndex of first row
[in]num_colsNumber of columns
[in]num_rowsNumber of rows

◆ writeLine()

template<typename T>
void isce3::io::gdal::Raster::writeLine ( const T * src,
int row )
inline

Write a line of pixel data to the raster.

The data will be converted from the input type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[in]srcSource values
[in]rowRow index

◆ writeLines()

template<typename T>
void isce3::io::gdal::Raster::writeLines ( const T * src,
int first_row,
int num_rows )
inline

Write one or more lines of pixel data to the raster.

The data will be converted from the input type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[in]srcSource values
[in]first_rowIndex of first row
[in]num_rowsNumber of rows

◆ writePixel()

template<typename T>
void isce3::io::gdal::Raster::writePixel ( const T * src,
int col,
int row )
inline

Write a single pixel value to the raster.

The data will be converted from the input type if different than the native datatype. If T is void, no conversion is performed.

Parameters
[in]srcSource value
[in]colColumn index
[in]rowRow index

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

Generated for ISCE3.0 by doxygen 1.13.2.