GeoProcessor / Command / RasterizeGeoLayer
Overview
The RasterizeGeoLayer
command creates a new raster GeoLayer from a vector GeoLayer
using the gdal:rasterize
algorithm.
See the latest QGIS rasterize documentation.
The resulting raster layer is written to an output file specified by the OutputFile
parameter or, if not specified,
a temporary file with timestamped filename to ensure uniqueness.
The GeoTIFF format is used for filenames specified with tif
extension and is the default format.
The rasterize output file is read as the raster GeoLayer if the GeoLayerID
parameter is specified or can be read with the
ReadRasterGeoLayerFromFile
command.
The rasterization occurs using one of the following approaches:
RasterUnits=GeoUnits
:- output units will be the units of the input vector layer, for example degrees if geographic coordinates
- specify
CellWidth
andCellHeight
parameters as the cell dimensions, where the values will be in the input layer's geographic units (e.g., degrees)
RasterUnits=Pixel
:- output units will be pixels, such as for an image
- specify
RasterWidth
andRasterHeight
parameters as the total width and height of the image, in pixels
The underlying software may retain a lock on the file.
The RasterizeGeoLayer
command attempts to remove the output file before running (to ensure that output is current)
and will warn if unsuccessful. This typically means that another program is using the file.
This issue should be fixed by the user because otherwise the old output may mistakenly be assumed to be current output.
The RasterizeGeoLayer
command also attempts to delete temporary files after reading (to avoid filling up the disk).
If unsuccessful, typically because underlying software has a lock on the file,
a warning will be logged to the log file and the file will remain.
The file is added to the list of files to be removed, which will be processed when the GeoProcessor is next started.
Command Editor
The following dialog is used to edit the command and illustrates the command syntax when using an automatically-generated temporary filename and reading into a GeoLayer.
RasterizeGeoLayer-GeoLayerID
Command Editor when Reading a GeoLayer (see full-size image)
The following illustrates the command syntax
when specifying the output file and not reading a GeoLayer.
A ReadRasterLayerFromFile
command can be used to read the file.
RasterizeGeoLayer-OutputFile
Command Editor when Not Reading a GeoLayer (see full-size image)
Command Syntax
The command syntax is as follows:
RasterizeGeoLayer(Parameter="Value",...)
Command Parameters
Parameter | Description | Default |
---|---|---|
GeoLayerID required |
The vector GeoLayer identifier. ${Property} syntax is recognized. |
None - must be specified. |
Attribute |
The attribute name that indicates values to be assigned in the raster layer. | Attribute or ConstantValue must be specified. |
OutputFile |
The output raster file (relative or absolute path). ${Property} syntax is recognized. |
Write to a temporary file. |
RasterFormat |
Format of the raster file that is created during processing:
|
GeoTIFF |
CellValueType |
Type for the cell values:
|
Byte |
RasterUnits |
Data units for raster layer:
|
None - must be specified. |
RasterWidth |
If RasterUnits=Pixels , the width of the image in pixels. |
|
RasterHeight |
If RasterUnits=Pixels , the height of the image in pixels. |
|
CellWidth |
If RasterUnits=GeoUnits , the width of a cell in raster units. |
|
CellHeight |
If RasterUnits=GeoUnits , the height of a cell in raster units. |
|
ConstantValue |
Constant value to assign to the raster rather than using Attribute value. |
|
MissingValue |
Value to use for missing or "no data" value. This indicates in the raster layer the attribute value that is used for missing values. | |
NewGeoLayerID |
GeoLayer identifier for the new raster layer. Formatting characters and ${Property} syntax is recognized. Refer to GeoLayerID documentation for best practices on GeoLayer identifiers. |
Create the raster layer file but don't read the layer. |
IfGeoLayerIDExists |
The action that occurs if the GeoLayerID already exists within the GeoProcessor:
|
Replace |
Examples
See the automated tests.
Troubleshooting
See Also
- QGIS rasterize documentation:
- QGIS latest rasterize algorithm documentation.
- QGIS 3.10 rasterize algorithm documentation.
ReadRasterGeoLayerFromFile
command