Rasterization¶
Reproject and rasterize a vector dataset
Description¶
Reproject and rasterize a vector dataset. The grid of the rasterized output can be set by using a reference image, or by setting all parameters (origin, size, spacing) by hand. In the latter case, at least the spacing (ground sampling distance) is needed (other parameters are computed automatically). The rasterized output can also be in a different projection reference system than the input dataset.
There are two rasterize mode available in the application. The first is the binary mode: it allows rendering all pixels belonging to a geometry of the input dataset in the foreground color, while rendering the other in background color. The second one allows rendering pixels belonging to a geometry with respect to an attribute of this geometry. The field of the attribute to render can be set by the user. In the second mode, the background value is still used for unassociated pixels.
Parameters¶
Input vector dataset -in vectorfile
Mandatory
The input vector dataset to be rasterized
Output image -out image [dtype]
Mandatory
An output image containing the rasterized vector dataset
Input reference image -im image
A reference image from which to import output grid and projection reference system information.
Output size x -szx int
Output size along x axis (useless if support image is given)
Output size y -szy int
Output size along y axis (useless if support image is given)
Output EPSG code -epsg int
EPSG code for the output projection reference system (EPSG 4326 for WGS84, 32631 for UTM31N…,useless if support image is given)
Output Upper-left x -orx float
Output upper-left corner x coordinate (useless if support image is given)
Output Upper-left y -ory float
Output upper-left corner y coordinate (useless if support image is given)
Spacing (GSD) x -spx float
Spacing (ground sampling distance) along x axis (useless if support image is given)
Spacing (GSD) y -spy float
Spacing (ground sampling distance) along y axis (useless if support image is given)
Background value -background float
Default value: 0
Default value for pixels not belonging to any geometry
Rasterization mode -mode [binary|attribute]
Default value: binary
Choice of rasterization modes
Binary mode
In this mode, pixels within a geometry will hold the user-defined foreground valueAttribute burning mode
In this mode, pixels within a geometry will hold the value of a user-defined field extracted from this geometry.
Binary mode options¶
Foreground value -mode.binary.foreground float
Default value: 255
Value for pixels inside a geometry
Attribute burning mode options¶
The attribute field to burn -mode.attribute.field string
Default value: DN
Name of the attribute field to burn
Available RAM (MB) -ram int
Default value: 256
Available memory for processing (in MB).
Examples¶
From the command-line:
otbcli_Rasterization -in qb_RoadExtract_classification.shp -out rasterImage.tif -spx 1. -spy 1.
From Python:
import otbApplication
app = otbApplication.Registry.CreateApplication("Rasterization")
app.SetParameterString("in", "qb_RoadExtract_classification.shp")
app.SetParameterString("out", "rasterImage.tif")
app.SetParameterFloat("spx", 1.)
app.SetParameterFloat("spy", 1.)
app.ExecuteAndWriteOutput()