Module Diff
See also

Aim of module

Calculates a difference grid model based on either two grids or a one grid and a horizontal reference plane.

General description

Difference models are a common product in the filed of ALS data processing. There are several fields of application like:

  • normalised Digital Surface Model (nDSM): The nDSM is calculated as DSM-DTM. The nDSM is a tool for checking the quality of the classification into terrain and off-terrain points (also referred to as filtering). Furthermore, the nDSM is the basis for many subsequent applications like building modelling or vegetation mapping.
  • first-last echo comparison: The penetrability of vegetation is characterised by the height differences between first and last echoes. A convenient way to derive such a measure is to compare the first-echo-DSM with the last-echo-DSM. The knowledge about penetrable areas can be used as additional input for ALS filtering.
  • strip differences: The calculation of relative height differences between overlapping ALS flight strip DSMs is of primary importance for checking the quality of a flight mission. Strip difference models can be used as basis for decision making, concerning the necessity of strip adjustment.
  • volume computation: Difference model between two surface grids or between a single surface grid and a horizontal reference plane can be used to quantify the amount of cuttings and fillings.
  • change detection: Difference models computed from surface grid models of different epoches can be used to identify height changes.

To derive a difference grid model either two input grid model files (parameter inFile) or a single model grid file and the height of a horizontal reference plane (parameter inFile/parameter refPlane, not yet implemented) have to be specified. The derived difference model (parameter outFile) is stored as a regular grid in GDAL supported data format (parameter oFormat). The difference grid model structure (grid width, tile size) is overtaken from the first input model, but the grid spacing can also be specified explicitly (parameter gridSize). Please note, that the derived grid model is strictly stored in "pixel is point" interpretation, i.e. the grid values represent z-differences at the pixel center. For a more detailed discussion "grid versus raster" please refer to the Glossary.

The difference calculation is carried out as 'inFile1 - inFile2 or 'inFile1 - zrefplane', respectively.

Parameter description

-inFile1st and 2nd input grid model file
Type: opals::Array<opals::Path, 2>
Remarks: mandatory
Specifies the two input grid model files in GDAL supported format as basis for the computation of a difference grid model
-outFileoutput difference grid model file
Type: opals::Path
Remarks: estimable
Specifies the name of the output difference grid model. The difference model is calculated as: diff model = 1st inFile - 2nd inFile. Estimation rule: current directory + 'diff_' + 1st inFile name + '_' + 2nd inFile name + extension corresponding to output format
-oFormatoutput grid file format [tif,asc,dem,dtm...]
Type: opals::String
Remarks: estimable
Grid file format, use GDAL driver names like GTiff, AAIGrid, USGSDEM, SCOP... . Estimation rule: estimated from the extension of the outFile; default (if neither oFormat nor outFile are specified): GTiff
-gridSizegrid width x/y
Type: double
Remarks: estimable
Size of output grid cell in x- and y-direction. Estimation rule: output grid size = grid size of 1st inFile
-noDatanodata value indicating void pixels
Type: opals::NoDataType
Remarks: default=max
Value representing an undefined value in the output grid model.
NoDataType: Defines or disables (use 'none') the nodata value for the output raster. The nodata values can be a specific value or a type independent label, such as, 'min', 'max' and 'nan'. Those labels will be translate to values based on the raster band type. See the OPALS Docu (opals::NoDataType) for more Details.
Syntax: none | min | max | nan | <value>
-limit2D clipping window
Type: opals::GridLimit
Remarks: optional
If no user defined limits are specified or -limit is even skipped, the common area (intersection) of the 1st and 2nd input grid model are used.
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 ')']
-applyTrafowhether transformation is applied on 1st or 2nd input grid model file
Type: opals::ApplyTrafo
Remarks: optional
Possible values:  
  first .... apply transformation to the first grid before subtracting
  second ... apply transformation to the second grid before subtracting
-trafogeometrically transform the data from 2nd inFile during diff
Type: opals::TrafPars3dAffine
Remarks: optional
An eventually passed affine 3-d transformation is applied during data comparison.
TrafPars3dAffine: Describes a relative or absolute 3D-affine transformation. This class contains the transformation parameters of an affine 3D (i.e. 12-parameter) transformation, given as 12-array
-resamplingpixel resampling method
Type: opals::ResamplingMethod
Remarks: default=bilinear
Possible values:  
  weightedAverage .... weighted average (low pass filter)
  simpleAverage ...... simple average (low pass filter)
  nearestNeighbour ... nearest neighbour
  bilinear ........... bi-linear interpolation
  bicubic ............ bi-cubic interpolation
  never .............. indicator avoiding resampling 
Method to be used for resampling the input grid to the specified gridSize of the resulting difference model.
-bandinput band name or band number
Type: opals::String
Remarks: default=0
To select the desired band of a multi-layer input raster file. Bands are numbered from 0.


The data used in the following example are located in the $OPALS_ROOT/demo/ directory. As the derivation of difference models relies on two input grid models, first ALS point data have to be imported and respective grid models have to be interpolated. For the example strips 11 and 21 contained in the demo directory the following commands are required to obtain DSM models for both ALS strips:

opalsImport -inf strip11.laz
opalsImport -inf strip21.laz
opalsGrid -inf strip11.odm -inter movingPlanes
opalsGrid -inf strip21.odm -inter movingPlanes

As a result, the two grid files strip21_z.tif and strip11_z.tif in GeoTiff format are created serving as input for the subsequent example.

Example 1:

In the first example only the mandatory parameter (inFile) and the resampling method is specified. Thus, the command is very short and simple:

opalsDiff -inFile strip21_z.tif strip11_z.tif -outFile diff_11_21.tif -resampling nearestNeighbour

The resulting output file name containing the difference model is diff_11_21.tif according to the estimation rules explained above. The resulting grid size is 1m, being the grid size of the first input grid model strip11_z.tif.

Example 2:

In the first example the resampling method nearest neighbour was used. This is fine, if the grid point locations coincide (as they do in our example). However, in case the grid point location don't coincide, it is better to use higher level resampling methods. In the following example the default resampling method bilinear is used:

opalsDiff -inFile strip11_z.tif strip21_z.tif -outFile diff_11_21.tif -oFormat GTiff -gridSize 1

Running the command:

opalsZColor -inf diff_11_21.tif -scale 0.06 -pal differencePal.xml

... using the predefined palette file differencesPalette.xml located in directory addons/pal, the following strip difference map will result:

Color coded strip difference map showing the rel. height differences between strips 11 and 21
@ scale
scanner range scale (opalsStripAdjust)
opalsZColor is the executable file of Module ZColor
Definition: ModuleExecutables.hpp:253
@ nearestNeighbour
nearest neighbour interpolation
@ movingPlanes
moving (tilted) plane interpolation
opalsDiff is the executable file of Module Diff
Definition: ModuleExecutables.hpp:53
opalsImport is the executable file of Module Import
Definition: ModuleExecutables.hpp:113
opalsGrid is the executable file of Module Grid
Definition: ModuleExecutables.hpp:93