Sample Selection
Brief Description
Selects samples from a training vector data set.
Tags
Learning
Long Description
The application selects a set of samples from geometries intended for training (they should have a field giving the associated class).
First of all, the geometries must be analyzed by the PolygonClassStatistics application to compute statistics about the geometries, which are summarized in an xml file.
Then, this xml file must be given as input to this application (parameter instats).
The input support image and the input training vectors shall be given in parameters 'in' and 'vec' respectively. Only the sampling grid (origin, size, spacing)will be read in the input image.
There are several strategies to select samples (parameter strategy) :
- smallest (default) : select the same number of sample in each class so that the smallest one is fully sampled.
- constant : select the same number of samples N in each class (with N below or equal to the size of the smallest class).
- byclass : set the required number for each class manually, with an input CSV file (first column is class name, second one is the required samples number).
- percent: set a target global percentage of samples to use. Class proportions will be respected.
- total: set a target total number of samples to use. Class proportions will be respected.
There is also a choice on the sampling type to performs :
- periodic : select samples uniformly distributed
- random : select samples randomly distributed
Once the strategy and type are selected, the application outputs samples positions(parameter out).
The other parameters to look at are :
- layer : index specifying from which layer to pick geometries.
- field : set the field name containing the class.
- mask : an optional raster mask can be used to discard samples.
- outrates : allows outputting a CSV file that summarizes the sampling rates for each class.
As with the PolygonClassStatistics application, different types of geometry are supported : polygons, lines, points.
The behavior of this application is different for each type of geometry :
- polygon: select points whose center is inside the polygon
- lines : select points intersecting the line
- points : select closest point to the provided point
Parameters
InputImage (in): Support image that will be classified
InputMask (mask): Validity mask (only pixels corresponding to a mask value greater than 0 will be used for statistics)
Input vectors (vec): Input geometries to analyse
Output vectors (out): Output resampled geometries
Input Statistics (instats): Input file storing statistics (XML format)
Output rates (outrates): Output rates (CSV formatted)
Sampler type (sampler): Type of sampling (periodic, pattern based, random)
Periodic sampler (periodic): Takes samples regularly spaced
Jitter amplitude (sampler.periodic.jitter): Jitter amplitude added during sample selection (0 = no jitter)
Random sampler (random): The positions to select are randomly shuffled.
Sampling strategy (strategy):
Set samples count for each class (byclass): Set samples count for each class
Number of samples by class (strategy.byclass.in): Number of samples by class (CSV format with class name in 1st column and required samples in the 2nd.
Set the same samples counts for all classes (constant): Set the same samples counts for all classes
Number of samples for all classes (strategy.constant.nb): Number of samples for all classes
Use a percentage of the samples available for each class (percent): Use a percentage of the samples available for each class
The percentage to use (strategy.percent.p): The percentage to use
Set the total number of samples to generate, and use class proportions. (total): Set the total number of samples to generate, and use class proportions.
The number of samples to generate (strategy.total.v): The number of samples to generate
Set same number of samples for all classes, with the smallest class fully sampled (smallest): Set same number of samples for all classes, with the smallest class fully sampled
Take all samples (all): Take all samples
Field Name (field): Name of the field carrying the class name in the input vectors.
Layer Index (layer): Layer index to read in the input vector file.
Elevation management (elev): 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): 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): 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): 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): Available memory for processing (in MB)
set user defined seed (rand): Set specific seed. with integer value.
Load otb application from xml file (inxml): Load otb application from xml file
Save otb application to xml file (outxml): Save otb application to xml file
Limitations
None
Authors
OTB-Team
See also
Example of use
in: support_image.tif
vec: variousVectors.sqlite
field: label
instats: apTvClPolygonClassStatisticsOut.xml
out: resampledVectors.sqlite
otbcli_SampleSelection -in support_image.tif -vec variousVectors.sqlite -field label -instats apTvClPolygonClassStatisticsOut.xml -out resampledVectors.sqlite