Class: QgsAlignRaster

class qgis.analysis.QgsAlignRaster

Bases: sip.wrapper

QgsAlignRaster takes one or more raster layers and warps (resamples) them so they have the same: - coordinate reference system - cell size and raster size - offset of the raster grid

New in version 2.12: Enums

Methods

alignedRasterExtent Returns the expected extent of the resulting aligned raster
alignedRasterSize Returns the expected size of the resulting aligned raster
cellSize Gets output cell size
checkInputParameters Determine destination extent from the input rasters and calculate derived values
clipExtent Gets clipping extent (region of interest).
createAndWarp Internal function for processing of one raster (1.
destinationCrs Gets the output CRS in WKT format
dump write contents of the object to standard error stream - for debugging
errorMessage Returns the error from a previous run() call.
gridOffset
progressHandler Gets associated progress handler.
rasters Gets list of rasters that will be aligned
run Run the alignment process
setCellSize Sets output cell size
setClipExtent Configure clipping extent (region of interest).
setDestinationCrs Sets the output CRS in WKT format
setGridOffset
setParametersFromRaster Set destination CRS, cell size and grid offset from a raster file.
setProgressHandler Assign a progress handler instance.
setRasters Sets list of rasters that will be aligned
suggestedReferenceLayer Returns the index of the layer which has smallest cell size (returns -1 on error)
suggestedWarpOutput Determine suggested output of raster warp to a different CRS.

Signals

Attributes

RA_Average
RA_Bilinear
RA_Cubic
RA_CubicSpline
RA_Lanczos
RA_Max
RA_Median
RA_Min
RA_Mode
RA_NearestNeighbour
RA_Q1
RA_Q3
class Item(input: str, output: str)

Bases: sip.wrapper

QgsAlignRaster.Item(QgsAlignRaster.Item)

inputFilename
outputFilename
resampleMethod
rescaleValues
srcCellSizeInDestCRS
class ProgressHandler

Bases: sip.wrapper

QgsAlignRaster.ProgressHandler(QgsAlignRaster.ProgressHandler)

progress(self, complete: float) → bool

Method to be overridden for progress reporting.

Parameters:complete – Overall progress of the alignment operation
Returns:False if the execution should be canceled, True otherwise
RA_Average = 5
RA_Bilinear = 1
RA_Cubic = 2
RA_CubicSpline = 3
RA_Lanczos = 4
RA_Max = 8
RA_Median = 10
RA_Min = 9
RA_Mode = 6
RA_NearestNeighbour = 0
RA_Q1 = 11
RA_Q3 = 12
class RasterInfo(layerpath: str)

Bases: sip.wrapper

Construct raster info with a path to a raster file

bandCount(self) → int

Returns the number of raster bands in the file

cellSize(self) → QSizeF

Returns the cell size in map units

crs(self) → str

Returns the CRS in WKT format

dump(self)

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

extent(self) → QgsRectangle

Returns the extent of the raster

gridOffset(self) → QPointF

Returns the grid offset

identify(self, mx: float, my: float) → float

Gets raster value at the given coordinates (from the first band)

isValid(self) → bool

Check whether the given path is a valid raster

origin(self) → QPointF

Returns the origin of the raster

rasterSize(self) → QSize

Returns the size of the raster grid in pixels

class ResampleAlg

Bases: int

alignedRasterExtent(self) → QgsRectangle

Returns the expected extent of the resulting aligned raster

Note

first need to run checkInputParameters() which returns with success

alignedRasterSize(self) → QSize

Returns the expected size of the resulting aligned raster

Note

first need to run checkInputParameters() which returns with success

cellSize(self) → QSizeF

Gets output cell size

checkInputParameters(self) → bool

Determine destination extent from the input rasters and calculate derived values

Returns:True on success, sets error on error (see errorMessage())
clipExtent(self) → QgsRectangle

Gets clipping extent (region of interest). No extra clipping is done if the rectangle is null

createAndWarp(self, raster: QgsAlignRaster.Item) → bool

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

destinationCrs(self) → str

Gets the output CRS in WKT format

dump(self)

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

errorMessage(self) → str

Returns the error from a previous run() call. Error message is empty if run() succeeded (returned True)

gridOffset(self) → QPointF
progressHandler(self) → QgsAlignRaster.ProgressHandler

Gets associated progress handler. May be None (default)

rasters(self) → object

Gets list of rasters that will be aligned

run(self) → bool

Run the alignment process

Returns:True on success, sets error on error (see errorMessage())
setCellSize(self, x: float, y: float)

Sets output cell size

setCellSize(self, size: QSizeF) Sets output cell size

setClipExtent(self, xmin: float, ymin: float, xmax: float, ymax: float)

Configure clipping extent (region of interest). No extra clipping is done if the rectangle is null

setClipExtent(self, extent: QgsRectangle) Configure clipping extent (region of interest). No extra clipping is done if the rectangle is null

setDestinationCrs(self, crsWkt: str)

Sets the output CRS in WKT format

setGridOffset(self, offset: Union[QPointF, QPoint])
setParametersFromRaster(self, rasterInfo: QgsAlignRaster.RasterInfo, customCRSWkt: str = '', customCellSize: QSizeF = QSizeF(), customGridOffset: Union[QPointF, QPoint] = QPointF(-1, -1)) → bool

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)

setParametersFromRaster(self, filename: str, customCRSWkt: str = ‘’, customCellSize: QSizeF = QSizeF(), customGridOffset: Union[QPointF, QPoint] = QPointF(-1,-1)) -> bool Overridden variant for convenience, taking filename instead RasterInfo object. See the other variant for details.

setProgressHandler(self, progressHandler: QgsAlignRaster.ProgressHandler)

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

setRasters(self, list: object)

Sets list of rasters that will be aligned

suggestedReferenceLayer(self) → int

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

suggestedWarpOutput(info: QgsAlignRaster.RasterInfo, destWkt: str, cellSize: QSizeF = None, gridOffset: Union[QPointF, QPoint] = None, rect: QgsRectangle = None) → bool

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