PolygonClassStatistics

Computes statistics on a training polygon set.

Description

Process a set of geometries intended for training (they should have a field giving the associated class). The geometries are analyzed against a support image to compute statistics:

  • Number of samples per class
  • Number of samples per geometry

An optional raster mask can be used to discard samples. Different types of geometry are supported: polygons, lines, points. The behaviour is different for each type of geometry:

  • Polygon: select pixels whose center is inside the polygon
  • Lines: select pixels intersecting the line
  • Points: select closest pixel to the point

This application has several output images and supports “multi-writing”. Instead of computing and writing each image independently, the streamed image blocks are written in a synchronous way for each output. The output images will be computed strip by strip, using the available RAM to compute the strip size, and a user defined streaming mode can be specified using the streaming extended filenames (type, mode and value). Note that multi-writing can be disabled using the multi-write extended filename option: &multiwrite=false, in this case the output images will be written one by one. Note that multi-writing is not supported for MPI writers.

Parameters

Input image -in image Mandatory
Support image that will be classified

Input validity mask -mask image
Validity mask (only pixels corresponding to a mask value greater than 0 will be used for statistics)

Input vectors -vec filename [dtype] Mandatory
Input geometries to analyze

Output XML statistics file -out filename [dtype] Mandatory
Output file to store statistics (XML format)

Field Name -field string
Name of the field carrying the class name in the input vectors.

Layer Index -layer int Default value: 0
Layer index to read in the input vector file.

Elevation management

This group of parameters allows managing elevation values. Supported formats are SRTM, DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a product.

DEM directory -elev.dem directory
This parameter allows selecting a directory containing Digital Elevation Model files. Note that this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in this directory.

Geoid File -elev.geoid filename [dtype]
Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).

Default elevation -elev.default float Default value: 0
This parameter allows setting the default height above ellipsoid when there is no DEM available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set. This is also used by some application as an average elevation value.


Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).

Examples

From the command-line:

otbcli_PolygonClassStatistics -in support_image.tif -vec variousVectors.sqlite -field CLASS -out polygonStat.xml

From Python:

import otbApplication

app = otbApplication.Registry.CreateApplication("PolygonClassStatistics")

app.SetParameterString("in", "support_image.tif")
app.SetParameterString("vec", "variousVectors.sqlite")
app.SetParameterString("field", "CLASS")
app.SetParameterString("out", "polygonStat.xml")

app.ExecuteAndWriteOutput()