QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
QgsAlignRaster Class Reference

QgsAlignRaster takes one or more raster layers and warps (resamples) them so they have the same: More...

#include <qgsalignraster.h>

Classes

struct  ProgressHandler
 Helper struct to be sub-classed for progress reporting. More...
 
struct  RasterInfo
 Utility class for gathering information about rasters. More...
 

Public Types

typedef QgsAlignRasterData::RasterItem Item
 
typedef QList< QgsAlignRasterData::RasterItemList
 
typedef Qgis::GdalResampleAlgorithm ResampleAlg
 

Public Member Functions

 QgsAlignRaster ()
 
QgsRectangle alignedRasterExtent () const
 Returns the expected extent of the resulting aligned raster. More...
 
QSize alignedRasterSize () const
 Returns the expected size of the resulting aligned raster. More...
 
QSizeF cellSize () const
 Gets output cell size. More...
 
bool checkInputParameters ()
 Determine destination extent from the input rasters and calculate derived values. More...
 
QgsRectangle clipExtent () const
 Gets clipping extent (region of interest). More...
 
QString destinationCrs () const
 Gets the output CRS in WKT format. More...
 
void dump () const
 write contents of the object to standard error stream - for debugging More...
 
QString errorMessage () const
 Returns the error from a previous run() call. More...
 
QPointF gridOffset () const
 
ProgressHandlerprogressHandler () const
 Gets associated progress handler. May be nullptr (default) More...
 
List rasters () const
 Gets list of rasters that will be aligned. More...
 
bool run ()
 Run the alignment process. More...
 
void setCellSize (double x, double y)
 Sets output cell size. More...
 
void setCellSize (QSizeF size)
 Sets output cell size. More...
 
void setClipExtent (const QgsRectangle &extent)
 Configure clipping extent (region of interest). More...
 
void setClipExtent (double xmin, double ymin, double xmax, double ymax)
 Configure clipping extent (region of interest). More...
 
void setDestinationCrs (const QString &crsWkt)
 Sets the output CRS in WKT format. More...
 
void setGridOffset (QPointF offset)
 
bool setParametersFromRaster (const QString &filename, const QString &customCRSWkt=QString(), QSizeF customCellSize=QSizeF(), QPointF customGridOffset=QPointF(-1, -1))
 Overridden variant for convenience, taking filename instead RasterInfo object. More...
 
bool setParametersFromRaster (const RasterInfo &rasterInfo, const QString &customCRSWkt=QString(), QSizeF customCellSize=QSizeF(), QPointF customGridOffset=QPointF(-1, -1))
 Set destination CRS, cell size and grid offset from a raster file. More...
 
void setProgressHandler (ProgressHandler *progressHandler)
 Assign a progress handler instance. Does not take ownership. nullptr can be passed. More...
 
void setRasters (const List &list)
 Sets list of rasters that will be aligned. More...
 
int suggestedReferenceLayer () const
 Returns the index of the layer which has smallest cell size (returns -1 on error) More...
 

Protected Member Functions

bool createAndWarp (const Item &raster)
 Internal function for processing of one raster (1. create output, 2. do the alignment) More...
 

Static Protected Member Functions

static bool suggestedWarpOutput (const RasterInfo &info, const QString &destWkt, QSizeF *cellSize=nullptr, QPointF *gridOffset=nullptr, QgsRectangle *rect=nullptr)
 Determine suggested output of raster warp to a different CRS. Returns true on success. More...
 

Protected Attributes

double mCellSizeX
 Destination cell size. More...
 
double mCellSizeY
 
double mClipExtent [4]
 Optional clip extent: sets "requested area" which be extended to fit the raster grid. More...
 
QString mCrsWkt
 Destination CRS - stored in well-known text (WKT) format. More...
 
QString mErrorMessage
 Last error message from run() More...
 
double mGeoTransform [6]
 Computed geo-transform. More...
 
double mGridOffsetX
 Destination grid offset - expected to be in interval <0,cellsize) More...
 
double mGridOffsetY
 
ProgressHandlermProgressHandler = nullptr
 Object that facilitates reporting of progress / cancellation. More...
 
List mRasters
 List of rasters to be aligned (with their output files and other options) More...
 
int mXSize
 Computed raster grid width. More...
 
int mYSize
 Computed raster grid height. More...
 

Detailed Description

QgsAlignRaster takes one or more raster layers and warps (resamples) them so they have the same:

Definition at line 44 of file qgsalignraster.h.

Member Typedef Documentation

◆ Item

Definition at line 110 of file qgsalignraster.h.

◆ List

Definition at line 111 of file qgsalignraster.h.

◆ ResampleAlg

Definition at line 109 of file qgsalignraster.h.

Constructor & Destructor Documentation

◆ QgsAlignRaster()

QgsAlignRaster::QgsAlignRaster ( )

Definition at line 114 of file qgsalignraster.cpp.

Member Function Documentation

◆ alignedRasterExtent()

QgsRectangle QgsAlignRaster::alignedRasterExtent ( ) const

Returns the expected extent of the resulting aligned raster.

Note
first need to run checkInputParameters() which returns with success

Definition at line 346 of file qgsalignraster.cpp.

◆ alignedRasterSize()

QSize QgsAlignRaster::alignedRasterSize ( ) const

Returns the expected size of the resulting aligned raster.

Note
first need to run checkInputParameters() which returns with success

Definition at line 341 of file qgsalignraster.cpp.

◆ cellSize()

QSizeF QgsAlignRaster::cellSize ( ) const
inline

Gets output cell size.

Definition at line 145 of file qgsalignraster.h.

◆ checkInputParameters()

bool QgsAlignRaster::checkInputParameters ( )

Determine destination extent from the input rasters and calculate derived values.

Returns
true on success, sets error on error (see errorMessage())

Definition at line 233 of file qgsalignraster.cpp.

◆ clipExtent()

QgsRectangle QgsAlignRaster::clipExtent ( ) const

Gets clipping extent (region of interest).

No extra clipping is done if the rectangle is null

Definition at line 141 of file qgsalignraster.cpp.

◆ createAndWarp()

bool QgsAlignRaster::createAndWarp ( const Item raster)
protected

Internal function for processing of one raster (1. create output, 2. do the alignment)

Definition at line 417 of file qgsalignraster.cpp.

◆ destinationCrs()

QString QgsAlignRaster::destinationCrs ( ) const
inline

Gets the output CRS in WKT format.

Definition at line 150 of file qgsalignraster.h.

◆ dump()

void QgsAlignRaster::dump ( ) const

write contents of the object to standard error stream - for debugging

Definition at line 372 of file qgsalignraster.cpp.

◆ errorMessage()

QString QgsAlignRaster::errorMessage ( ) const
inline

Returns the error from a previous run() call.

Error message is empty if run() succeeded (returned true)

Definition at line 217 of file qgsalignraster.h.

◆ gridOffset()

QPointF QgsAlignRaster::gridOffset ( ) const
inline

Definition at line 138 of file qgsalignraster.h.

◆ progressHandler()

ProgressHandler * QgsAlignRaster::progressHandler ( ) const
inline

Gets associated progress handler. May be nullptr (default)

Definition at line 130 of file qgsalignraster.h.

◆ rasters()

List QgsAlignRaster::rasters ( ) const
inline

Gets list of rasters that will be aligned.

Definition at line 135 of file qgsalignraster.h.

◆ run()

bool QgsAlignRaster::run ( )

Run the alignment process.

Returns
true on success, sets error on error (see errorMessage())

Definition at line 352 of file qgsalignraster.cpp.

◆ setCellSize() [1/2]

void QgsAlignRaster::setCellSize ( double  x,
double  y 
)
inline

Sets output cell size.

Definition at line 141 of file qgsalignraster.h.

◆ setCellSize() [2/2]

void QgsAlignRaster::setCellSize ( QSizeF  size)
inline

Sets output cell size.

Definition at line 143 of file qgsalignraster.h.

◆ setClipExtent() [1/2]

void QgsAlignRaster::setClipExtent ( const QgsRectangle extent)

Configure clipping extent (region of interest).

No extra clipping is done if the rectangle is null

Definition at line 135 of file qgsalignraster.cpp.

◆ setClipExtent() [2/2]

void QgsAlignRaster::setClipExtent ( double  xmin,
double  ymin,
double  xmax,
double  ymax 
)

Configure clipping extent (region of interest).

No extra clipping is done if the rectangle is null

Definition at line 127 of file qgsalignraster.cpp.

◆ setDestinationCrs()

void QgsAlignRaster::setDestinationCrs ( const QString &  crsWkt)
inline

Sets the output CRS in WKT format.

Definition at line 148 of file qgsalignraster.h.

◆ setGridOffset()

void QgsAlignRaster::setGridOffset ( QPointF  offset)
inline

Definition at line 137 of file qgsalignraster.h.

◆ setParametersFromRaster() [1/2]

bool QgsAlignRaster::setParametersFromRaster ( const QString &  filename,
const QString &  customCRSWkt = QString(),
QSizeF  customCellSize = QSizeF(),
QPointF  customGridOffset = QPointF( -1, -1 ) 
)

Overridden variant for convenience, taking filename instead RasterInfo object.

See the other variant for details.

Definition at line 148 of file qgsalignraster.cpp.

◆ setParametersFromRaster() [2/2]

bool QgsAlignRaster::setParametersFromRaster ( const RasterInfo rasterInfo,
const QString &  customCRSWkt = QString(),
QSizeF  customCellSize = QSizeF(),
QPointF  customGridOffset = QPointF( -1, -1 ) 
)

Set destination CRS, cell size and grid offset from a raster file.

The user may provide custom values for some of the parameters - in such case only the remaining parameters are calculated.

If default CRS is used, the parameters are set according to the raster file's geo-transform. If a custom CRS is provided, suggested reprojection is calculated first (using GDAL) in order to determine suitable defaults for cell size and grid offset.

Returns
true on success (may fail if it is not possible to reproject raster to given CRS)

Definition at line 153 of file qgsalignraster.cpp.

◆ setProgressHandler()

void QgsAlignRaster::setProgressHandler ( ProgressHandler progressHandler)
inline

Assign a progress handler instance. Does not take ownership. nullptr can be passed.

Definition at line 128 of file qgsalignraster.h.

◆ setRasters()

void QgsAlignRaster::setRasters ( const List list)
inline

Sets list of rasters that will be aligned.

Definition at line 133 of file qgsalignraster.h.

◆ suggestedReferenceLayer()

int QgsAlignRaster::suggestedReferenceLayer ( ) const

Returns the index of the layer which has smallest cell size (returns -1 on error)

Definition at line 385 of file qgsalignraster.cpp.

◆ suggestedWarpOutput()

bool QgsAlignRaster::suggestedWarpOutput ( const RasterInfo info,
const QString &  destWkt,
QSizeF *  cellSize = nullptr,
QPointF *  gridOffset = nullptr,
QgsRectangle rect = nullptr 
)
staticprotected

Determine suggested output of raster warp to a different CRS. Returns true on success.

Definition at line 508 of file qgsalignraster.cpp.

Member Data Documentation

◆ mCellSizeX

double QgsAlignRaster::mCellSizeX
protected

Destination cell size.

Definition at line 249 of file qgsalignraster.h.

◆ mCellSizeY

double QgsAlignRaster::mCellSizeY
protected

Definition at line 249 of file qgsalignraster.h.

◆ mClipExtent

double QgsAlignRaster::mClipExtent[4]
protected

Optional clip extent: sets "requested area" which be extended to fit the raster grid.

Clipping not done if all coords are zeroes.

Definition at line 257 of file qgsalignraster.h.

◆ mCrsWkt

QString QgsAlignRaster::mCrsWkt
protected

Destination CRS - stored in well-known text (WKT) format.

Definition at line 247 of file qgsalignraster.h.

◆ mErrorMessage

QString QgsAlignRaster::mErrorMessage
protected

Last error message from run()

Definition at line 241 of file qgsalignraster.h.

◆ mGeoTransform

double QgsAlignRaster::mGeoTransform[6]
protected

Computed geo-transform.

Definition at line 262 of file qgsalignraster.h.

◆ mGridOffsetX

double QgsAlignRaster::mGridOffsetX
protected

Destination grid offset - expected to be in interval <0,cellsize)

Definition at line 251 of file qgsalignraster.h.

◆ mGridOffsetY

double QgsAlignRaster::mGridOffsetY
protected

Definition at line 251 of file qgsalignraster.h.

◆ mProgressHandler

ProgressHandler* QgsAlignRaster::mProgressHandler = nullptr
protected

Object that facilitates reporting of progress / cancellation.

Definition at line 238 of file qgsalignraster.h.

◆ mRasters

List QgsAlignRaster::mRasters
protected

List of rasters to be aligned (with their output files and other options)

Definition at line 244 of file qgsalignraster.h.

◆ mXSize

int QgsAlignRaster::mXSize
protected

Computed raster grid width.

Definition at line 264 of file qgsalignraster.h.

◆ mYSize

int QgsAlignRaster::mYSize
protected

Computed raster grid height.

Definition at line 267 of file qgsalignraster.h.


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