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
Returns the expected extent of the resulting aligned raster
Returns the expected size of the resulting aligned raster
Gets output cell size
Determine destination extent from the input rasters and calculate derived values
Gets clipping extent (region of interest).
Internal function for processing of one raster (1.
Gets the output CRS in WKT format
write contents of the object to standard error stream - for debugging
Returns the error from a previous run() call.
Gets associated progress handler.
Gets list of rasters that will be aligned
Run the alignment process
Sets output cell size
Configure clipping extent (region of interest).
Sets the output CRS in WKT format
Set destination CRS, cell size and grid offset from a raster file.
Assign a progress handler instance.
Sets list of rasters that will be aligned
Returns the index of the layer which has smallest cell size (returns -1 on error)
Determine suggested output of raster warp to a different CRS.
Signals
Attributes
-
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) → List[QgsAlignRaster.Item]¶ 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: Iterable[QgsAlignRaster.Item])¶ 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
-
class