pktools 2.6.7
Processing Kernel for geospatial data
pkextractimg

extract pixel values from raster image using a raster sample

SYNOPSIS

Usage: pkextractimg -i input -s sample -o output

Options: [-c class]* [-t threshold]* [-f format] [-ft fieldType] [-lt labelType] [-b band]*

Advanced options: [-sband band -eband band]* [-bndnodata band [-srcnodata value]*] [-bn attribute] [-cn attribute] [-down value]

Description

The utility pkextractimg extracts pixel values from an input raster dataset, based on the locations you provide via a sample file. The sample should be a raster dataset with categorical (integer) values. The typical use case is a land cover map that overlaps the input raster dataset. The utility then extracts pixels from the input raster for the respective land cover classes. To select a random subset of the sample raster dataset you can set the threshold option -t with a percentage value. You can provide a threshold value for each class (e.g. -t 80 -t 60). Use value 100 to select all pixels for selected class(es). As output, a new copy of the vector file is created with an extra attribute for the extracted pixel value. For each raster band in the input image, a separate attribute is created. For instance, if the raster dataset contains three bands, three attributes are created (b0, b1 and b2).

Options

  • use either -short or --long options (both --long=value and --long value are supported)
  • short option -h shows basic options only, long option --help shows all options
    short long type default description
    i input std::string Raster input dataset containing band information
    s sample std::string Raster dataset with categorical values to sample the input raster dataset. Output will contain features with input band information included
    o output std::string Output sample dataset
    c class int Class(es) to extract from input sample image. Leave empty to extract all valid data pixels from sample dataset
    t threshold float 100 Probability threshold for selecting samples (randomly). Provide probability in percentage (>0) or absolute (<0). You can provide a threshold value for each class (e.g. -t 80 -t 60). Use value 100 to select all pixels for selected class(es)
    f f std::string SQLite Output sample dataset format
    ft ftype std::string Real Field type (only Real or Integer)
    lt ltype std::string Integer Label type: In16 or String
    b band int Band index(es) to extract (0 based). Leave empty to use all bands
    sband startband unsigned short Start band sequence number
    eband endband unsigned short End band sequence number
    bndnodata bndnodata int 0 Band in input image to check if pixel is valid (used for srcnodata)
    srcnodata srcnodata double Invalid value(s) for input image
    bn bname std::string b For single band input data, this extra attribute name will correspond to the raster values. For multi-band input data, multiple attributes with this prefix will be added (e.g. b0, b1, b2, etc.)
    cn cname std::string label Name of the class label in the output vector dataset
    down down short 1 Down sampling factor

Usage: pkextractimg -i input [-s sample] -o output

Examples

Some examples how to use pkextractimg can be found here