Module Rasterize

opals::IRasterize

# Aim of module

Performs vector-to-raster conversion for all types of simple feature geometries (points, lines, polygons).

# General description

The main functionality of this module is to create a raster file from an ODM input file. The rasterizing process is a 2D operation where fixed or variable values are written to the output raster at the 2D location of the geometry objects. Per default a fixed value of 1 is used to 'burn' the geometries into the output raster. Variable burn values can either be the z values of the objects or attribute values that were attached to the geometry objects. Use parameter attribute to specify a fixed value or the corresponding attribute name.

The output file must be a format that is supported by GDAL (c.f. parameter oFormat)

This module burns all geometries types (points, polylines and polygons) into the first raster band of the output file. Whereas polylines represent linear structure, polygons describe areas resulting in filled raster objects (see figures below). In case of overlapping objects, the value of the last geometry will be stored in the output raster.

The following image shows a simple point to raster conversion. Different colours represent different z values of the rasterized points. If the raster is binary (default) the raster pixels will be 0 or 1. The Example 1 shows an raster image of a small LiDAR dataset.

Points Rasterization

Whereas Module Cell can be equally used for rasterzing point coulds, the rasterize module is also able to rasterize polylines. Polyline rasterization with defined attribute is shown in the following image. The shown polyline is defined by three points. The module interpolates between the line vertices in a linear manner.

Polyline Rasterization

As it can be seen below, polygons can also be rasterized by the module. Whereas rasterization of polylines with attribute z is straight forward, things get complicated for polygons since it's not directly possible to linear interpolate value for pixel inside the polygons. The implemented algorithm builds a Constraint Delaunay Triangulation from the polygon and rasters relevant triangles. Doing so it is possible to linear interpolate value for the inside pixels. The following figure shows a simple polygon using fixed value (centre) or variable values (right) burning.

Polygon Rasterization

The cellSize is a mandatory field that the user has to input according to the precision that the user needs. The user must provide one or two double values as the raster cell size (one value results in squared pixels). The raster extents are either derived automatically based on the (xy-) extents of input data or can be specified by the user limit. Optionally, a value indicating data voids noData can be defined.

In some cases it is useful to consider only a subset of the data, e.g. to rasterize all last echoes only. For this purpose, OPALS provides a general concept for filtering input data (parameter filter). See here for details.

Module Rasterize

# Parameter description

-inFileinput file
Type: opals::Path
Remarks: mandatory
The specified input file are imported in the same order as defined. To append data to an opalsDM file, specify the opalsDM file as input and outFile.
-outFileoutput raster file
Type: opals::Path
Remarks: estimable
Path of filtered raster image file in GDAL supported format.
Estimation rule: The current directory and the name (body) of the input file are used as file name basis. Additionally, the postfix '_ras' is appended and the extension is constructed according to the specified oFormat (e.g. '.tif').
-oFormatraster file format [GTiff,AAIGrid,SCOP,...]
Type: opals::String
Remarks: estimable
Use GDAL driver names like GTiff, AAIGrid, USGSDEM, SCOP... .
Estimation rule: The output format is estimated based on the extension of the output file (*.tif->GTiff, *.dem->USGSDEM, *.dtm->SCOP...).
-cellSizeraster cell size x/y
Type: opals::Vector<double>
Remarks: default=10 10
Size of the rectangular grid cell in x- and y-direction. If only one value is passed, quadratic cells are used.
-limit2D clipping window
Type: opals::GridLimit
Remarks: optional
If no user defined limits are specified or -limit is even skipped, the OPALS Data Manager (ODM) extents are used. Rounding is enabled by default in case the limits are derived from the ODM and can be enforced for user defined limits (keyword: round).
GridLimit: Defines xy-limits for output grid/raster datasets. The limit coordinates specified by left/lower/right/upper either refer to pixel centers (default) or corners, and may optionally get rounded to multiples of the grid size.
Syntax: ['center'|'corner']['round']['(' left lower right upper ')']
-attributeattribute from which the raster shall be derived if no attribute defined the burn z value will be 1.
Type: opals::String
Remarks: optional
Valid attributes are either coordinates (x, y, z) or additional infos like Amplitude, EchoWidth etc.)
-filterModify the input using a (tree of) filter(s)
Type: opals::String
Remarks: default=
Text string describing a (tree of) filter(s) using the WKT filter syntax.
-noDataNodata value
Type: double
Remarks: default=9999
Value indicating data voids. Value representing an undefined value in the output raster model.
-initValuePre-initialize cellValue
Type: double
Remarks: optional
If only one value is given, the same value is used in all the bands.

# Examples

Example 1: Rasterize point cloud file filled with points

opalsImport -inf fullwave.las -outFile fullwave.odm
opalsRasterize -inFile fullwave.odm -outfile fullwave.tif -cellSize 1 1 -attribute z

Executing the above command will create the file fullwave.tif. According to the command syntax the cell size is 1 x 1 and the attribute used is Z (i.e. elevation).

Example 2: Rasterize point cloud file filled with points

opalsImport -inf fullwave.las -outFile fullwave.odm
opalsRasterize -inFile fullwave.odm -outfile fullwave_binary.tif -cellSize 1 1

Executing the above command will export the file fullwave.tif. According to the command syntax the cell size is 1*1 and there is no specific attribute set, which means that the raster file will use binary values as Z value.

Without using any attribute, if it's not necessary, will reduce the execution time and the file size also.

Example 3: Example Using different attribute and Filter

opalsImport -inf fullwave.las -outFile fullwave.odm
opalsRasterize -inFile fullwave.odm -outfile fullwaveAF.tif -cellSize 1 -attribute Amplitude -filter Echo[Last]

The example above shows the difference when using different attribute and the filter functionality. For more detailed information about pre-selecting data please refer to the Filter manual.

Result raster using Amplitude as Attribute and Filter Echo[Last]

Example 4: Rasterize point cloud file filled with polygons

opalsImport -inf polygons3.shp -outFile polygons3.odm
opalsRasterize -inFile polygons3.odm -outfile polygons.tif -cellSize 0.5 0.5

In the following screenshot three polygons are converted to raster polygons.The image of the left shows the vector polygon within the odm file

Rasterize Polygons(left) and Polygon in the odm file(right)

Changing the cellSize will improve the resolution of raster image, but will increase the output file size and will increase the execution time of the Rasterize Module. In this example the execution time is not critical because the files are very small but using larger files the difference in execution time is obvious and not trivial.

Example 5: Rasterize point polygons with given limits

opalsImport -inf polygons3.shp -outFile polygons3.odm
opalsRasterize -inFile polygons3.odm -outfile polygons_limit.tif -cellSize 0.5 0.5 -limit "(24855 311159 24961 311227)"

The following image shows the rasterize module output using limit parameter. As shown in the image when a polygon is in between the limits,the part which is inside the limit is rasterized only. The following image could be compared with the images in Example 3.

Rasterized Polygons using limits constrains.

This option helps the user to rasterize only the area that is interested in. The polygons or other geometry division is handled automatically by the module.

Example 6: Rasterize point cloud file filled with multilines and points

opalsImport -inf ens2000.wnp -outFile ens2000.odm -iFormat WNP
opalsRasterize -inFile ens2000.odm -outfile multiline_T.tif -cellSize 1 1 -attribute z
Multiline Rasterize file.

Example 7: Different geometry types within one file The following example creates an ODM containing two points, a polyline and a polygon using the pyDM python package. Then, the vector data are rasterized.

python createODM4Rasterize.py
opalsRasterize -inFile demoRasterize.odm -outfile demoRasterize.tif -cellSize 1 1 -attribute z
Points, Polyline, Polygon in the same file.

Example 8: Polygon and variable burn values The following example demonstrates a file that consists of a polygon and which is rasterized using z as variable burn values. Like points and polylines the cells different colour of points in the polygon file shows that the z value is different from cell to cell. In this example we select the cell size 0.5 to increase the accuracy of the output raster file.

3D Polygons rasterization.

# References

Date
29.7.2016
opalsImport is the executable file of Module Import
Definition: ModuleExecutables.hpp:113
@ Amplitude
Linear scale value proportional to the receiving power.
This is the fake namespace of all opals Python scripts.
Definition: doc/temp_doxy/python/__init__.py:1
@ filter
string to be parsed in construction of DM::IFilter (various modules)
opalsRasterize is the executable file of Module Rasterize
Definition: ModuleExecutables.hpp:178