pktools  2.6.7
Processing Kernel for geospatial data
pkextractogr

extract pixel values from raster image using a vector dataset sample

SYNOPSIS

Usage: pkextractogr -i input [-s sample | -rand number | -grid size] -o output

Options: [-ln layer]* [-c class]* [-t threshold]* [-f format] [-ft fieldType] [-b band]* [-r rule]*

Advanced options: [-sband band -eband band]* [-bndnodata band -srcnodata value]* [-tp threshold] [-buf value [-circ]]

Description

The utility pkextractogr extracts pixel values from an input raster dataset, based on the locations you provide via a sample file. Alternatively, a random sample or systematic grid of points can also be extracted. The sample can be a vector file with points or polygons. In the case of polygons, you can either extract the values for all raster pixels that are covered by the polygons, or extract a single value for each polygon such as the centroid, mean, median, etc. 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).

A typical usage of pkextractogr is to prepare a training sample for one of the classifiers implemented in pktools.

Overview of the possible extraction rules:

pkextractogr_rules

extraction rule output features
point extract a single pixel within the polygon or on each point feature
allpoints Extract all pixel values covered by the polygon
centroid Extract pixel value at the centroid of the polygon
mean Extract average of all pixel values within the polygon
stdev Extract standard deviation of all pixel values within the polygon
median Extract median of all pixel values within the polygon
min Extract minimum value of all pixels within the polygon
max Extract maximum value of all pixels within the polygon
sum Extract sum of the values of all pixels within the polygon
mode Extract the mode of classes within the polygon (classes must be set with the option class)
proportion Extract proportion of class(es) within the polygon (classes must be set with the option class)
count Extract count of class(es) within the polygon (classes must be set with the option class).
percentile Extract percentile as defined by option perc (e.g, 95th percentile of values covered by polygon)

Options

Examples

Some examples how to use pkextractogr can be found here