4.2.2 Rasterization

Rasterize a vector dataset.

Detailed description

This application allows reprojecting and rasterize a vector dataset. The grid of the rasterized output can be set by using a reference image, or by setting all parmeters (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 woth 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

This section describes in details the parameters available for this application. Table 4.30, page 475 presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is Rasterization.





Parameter key

Parameter type

Parameter description




in

Input vector data

Input vector dataset

out

Output image

Output image

im

Input image

Input reference image

szx

Int

Output size x

szy

Int

Output size y

epsg

Int

Output EPSG code

orx

Float

Output Upper-left x

ory

Float

Output Upper-left y

spx

Float

Spacing (GSD) x

spy

Float

Spacing (GSD) y

background

Float

Background value

mode

Choices

Rasterization mode

mode binary

Choice

Binary mode

mode attribute

Choice

Attribute burning mode

mode.binary.foreground

Float

Foreground value

mode.attribute.field

String

The attribute field to burn

ram

Int

Available RAM (Mb)

inxml

XML input parameters file

Load otb application from xml file

outxml

XML output parameters file

Save otb application to xml file











Table 4.30: Parameters table for Rasterization.

Input vector dataset The input vector dataset to be rasterized

Output image An output image containing the rasterized vector dataset

Input reference image A reference image from which to import output grid and projection reference system information.

Output size x Output size along x axis (useless if support image is given)

Output size y Output size along y axis (useless if support image is given)

Output EPSG code 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 Output upper-left corner x coordinate (useless if support image is given)

Output Upper-left y Output upper-left corner y coordinate (useless if support image is given)

Spacing (GSD) x Spacing (ground sampling distance) along x axis (useless if support image is given)

Spacing (GSD) y Spacing (ground sampling distance) along y axis (useless if support image is given)

Background value Default value for pixels not belonging to any geometry

Rasterization mode Choice of rasterization modes Available choices are:

Available RAM (Mb) Available memory for processing (in MB)

Load otb application from xml file Load otb application from xml file

Save otb application to xml file Save otb application to xml file

Example

To run this example in command-line, use the following:

otbcli_Rasterization -in qb_RoadExtract_classification.shp -out rasterImage.tif -spx 1. -spy 1.

To run this example from Python, use the following code snippet:

#!/usr/bin/python 
 
# Import the otb applications package 
import otbApplication 
 
# The following line creates an instance of the Rasterization application 
Rasterization = otbApplication.Registry.CreateApplication("Rasterization") 
 
# The following lines set all the application parameters: 
Rasterization.SetParameterString("in", "qb_RoadExtract_classification.shp") 
 
Rasterization.SetParameterString("out", "rasterImage.tif") 
 
Rasterization.SetParameterFloat("spx", 1.) 
 
Rasterization.SetParameterFloat("spy", 1.) 
 
# The following line execute the application 
Rasterization.ExecuteAndWriteOutput()

Limitations

None

Authors

This application has been written by OTB-Team.

See also

These additional ressources can be useful for further information: