Create classification dataset (from categorized vector layer and feature raster)

Create a classification dataset by sampling data for pixels that match the given categories and store the result as a pickle file. If the layer is not categorized, or the field with class values is selected manually, categories are derived from the sampled target data y. To be more precise: i) category values are derived from unique attribute values (after excluding no data or zero data values), ii) category names are set equal to the category values, and iii) category colors are picked randomly.

Usage:

  1. Open the algorithm from the processing toolbox.

  2. Select a vector layer containing your classes as well as a raster feature layer, e. g. your image, then click run.

    ../../../../_images/classvectorraster.png
  3. The output classification dataset will be listed under Models in your Data Sources panel.

Parameters

Categorized vector layer [vector]

Categorized vector layer specifying sample locations and target data y. If required, the layer is reprojected and rasterized internally to match the feature raster grid.

Raster layer with features [raster]

Raster layer used for sampling feature data X.

Exclude bad bands [boolean]

Whether to exclude bands, that are marked as bad bands, or contain no data, inf or nan values in all samples.

Default: True

Field with class values [field]

Field with class values used as target data y. If not selected, the field defined by the renderer is used. If that is also not specified, an error is raised.

Minimum pixel coverage [%] [number]

Exclude all pixel where (polygon) coverage is smaller than given threshold.

Default: 50

Majority voting [boolean]

Whether to use majority voting. Turn off to use simple nearest neighbour resampling, which is much faster, but may result in highly inaccurate class decisions.

Default: True

Outputs

Output dataset [fileDestination]

Dataset file destination.

Command-line usage

>qgis_process help enmapbox:CreateClassificationDatasetFromCategorizedVectorLayerAndFeatureRaster:

----------------
Arguments
----------------

categorizedVector: Categorized vector layer
    Argument type:  vector
    Acceptable values:
            - Path to a vector layer
featureRaster: Raster layer with features
    Argument type:  raster
    Acceptable values:
            - Path to a raster layer
excludeBadBands: Exclude bad bands (optional)
    Default value:  true
    Argument type:  boolean
    Acceptable values:
            - 1 for true/yes
            - 0 for false/no
            - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field
            - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression
categoryField: Field with class values (optional)
    Argument type:  field
    Acceptable values:
            - The name of an existing field
            - ; delimited list of existing field names
coverage: Minimum pixel coverage [%]
    Default value:  50
    Argument type:  number
    Acceptable values:
            - A numeric value
            - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field
            - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression
majorityVoting: Majority voting
    Default value:  true
    Argument type:  boolean
    Acceptable values:
            - 1 for true/yes
            - 0 for false/no
            - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field
            - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression
outputClassificationDataset: Output dataset
    Argument type:  fileDestination
    Acceptable values:
            - Path for new file

----------------
Outputs
----------------

outputClassificationDataset: <outputFile>
    Output dataset