---
name: "pkextractimg"
section: "1"
platform: "linux"
package: "pktools"
version: "2.6.7.6+ds-6+b3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pkextractimg"
---

# pkextractimg(1)

extract pixel values from raster image using a raster sample

## NAME

pkextractimg - extract pixel values from raster image using a raster sample

## SYNOPSIS

FC**pkextractimg**F\[0\]  FC**-i**F\[0\] *input* \[FC**-s**F\[0\] *sample*\] FC**-o**F\[0\] *output* \[*options*\]

## DESCRIPTION

**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 FC**-t**F\[0\] with a percentage value. You can provide a threshold value for each class (e.g. FC**-t**F\[0\] *80* FC**-t**F\[0\] *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

- FC**-i**F\[0\] *filename*, FC**--input**F\[0\] *filename*

  Raster input dataset containing band information

- FC**-s**F\[0\] *sample*, FC**--sample**F\[0\] *sample*

  Raster dataset with categorical values to sample the input raster dataset. Output will contain features with input band information included.

- FC**-ln**F\[0\] *layer*, FC**--ln**F\[0\] *layer*

  Layer name(s) in sample (leave empty to select all)

- FC**-rand**F\[0\] *number*, FC**--random**F\[0\] *number*

  Create simple random sample of points. Provide number of points to generate

- FC**-grid**F\[0\] *size*, FC**--grid**F\[0\] *size*

  Create systematic grid of points. Provide cell grid size (in projected units, e.g,. m)

- FC**-o**F\[0\] *filename*, FC**--output**F\[0\] *filename*

  Output sample dataset

- FC**-c**F\[0\] *class*, FC**--class**F\[0\] *class*

  Class(es) to extract from input sample image. Leave empty to extract all valid data pixels from sample dataset. Make sure to set classes if rule is set to mode, proportion or count.

- FC**-t**F\[0\] *threshold*, FC**--threshold**F\[0\] *threshold*

  Probability threshold for selecting samples (randomly). Provide probability in percentage (\>0) or absolute (\<0). Use a single threshold per vector sample layer. If using raster land cover maps as a sample dataset, you can provide a threshold value for each class (e.g. FC**-t**F\[0\] *80* FC**-t**F\[0\] *60*). Use value 100 to select all pixels for selected class(es)

- FC**-f**F\[0\] *format*, FC**--f**F\[0\] *format*

  Output sample dataset format

- FC**-ft**F\[0\] *fieldType*, FC**--ftype**F\[0\] *fieldType*

  Field type (only Real or Integer)

- FC**-lt**F\[0\] *labelType*, FC**--ltype**F\[0\] *labelType*

  Label type: In16 or String

- FC**-b**F\[0\] *band*, FC**--band**F\[0\] *band*

  Band index(es) to extract. Leave empty to use all bands

- FC**-sband**F\[0\] *band*, FC**--startband**F\[0\] *band*

  Start band sequence number

- FC**-eband**F\[0\] *band*, FC**--endband**F\[0\] *band*

  End band sequence number

- FC**-bndnodata**F\[0\] *band*, FC**--bndnodata**F\[0\] *band*

  Band(s) in input image to check if pixel is valid (used for srcnodata)

- FC**-srcnodata**F\[0\] *value*, FC**--srcnodata**F\[0\] *value*

  Invalid value(s) for input image

- FC**-bn**F\[0\] *attribute*, FC**--bname**F\[0\] *attribute*

  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.)

- FC**-cn**F\[0\] *attribute*, FC**--cname**F\[0\] *attribute*

  Name of the class label in the output vector dataset

- FC**-down**F\[0\] *value*, FC**--down**F\[0\] *value*

  Down sampling factor

- FC**-v**F\[0\] *level*, FC**--verbose**F\[0\] *level*

  Verbose mode if \> 0
