logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

pkextractogr - extract pixel values from raster image from a (vector or raster) sample

Description

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 ex‐
       tra attribute for the extracted pixel value.  For each raster band in the input  image,  a  separate  at‐
       tribute  is created.  For instance, if the raster dataset contains three bands, three attributes are cre‐
       ated (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:
       Extraction rule   Output features
       point             Extract all pixel values  covered  by
                         the polygon (option -polygon not set)
                         or extract a pixel on the surface op‐
                         tion (-polygon set).
       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 pix‐
                         els 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) with‐
                         in  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  op‐
                         tion  perc  (e.g,  95th percentile of
                         values covered by polygon).

Name

       pkextractogr - extract pixel values from raster image from a (vector or raster) sample

Options

-ifilename, --inputfilename
              Raster input dataset containing band information

       -ssample, --samplesample
              OGR vector dataset with features to be extracted from input data.  Output  will  contain  features
              with input band information included.  Sample image can also be GDAL raster dataset.

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

       -randnumber, --randomnumber
              Create simple random sample of points.  Provide number of points to generate

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

       -ofilename, --outputfilename
              Output sample dataset Output sample dataset

       -cclass, --classclass
              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.

       -tthreshold, --thresholdthreshold
              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. -t80-t60).  Use
              value 100 to select all pixels for selected class(es)

       -percpercentile, --percpercentile
              Percentile value used for rule percentile

       -fformat, --fformat
              Output sample dataset format

       -ftfieldType, --ftypefieldType
              Field type (only Real or Integer)

       -ltlabelType, --ltypelabelType
              Label type: In16 or String

       -bband, --bandband
              Band index(es) to extract.  Leave empty to use all bands

       -sbandband, --startbandband
              Start band sequence number

       -ebandband, --endbandband
              End band sequence number

       -rrule, --rulerule
              Rule how to report image information per feature (only for vector sample).  point (value  at  each
              point  or  at  centroid  if  polygon), centroid, mean, stdev, median, proportion, count, min, max,
              mode, sum, percentile.

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

       -srcnodatavalue, --srcnodatavalue
              Invalid value(s) for input image

       -tpthreshold, --thresholdPolygonthreshold
              (absolute) threshold for selecting samples in each polygon

       -bufvalue, --buffervalue
              Buffer for calculating statistics for point features

       -circ, --circular
              Use a circular disc kernel buffer (for vector point sample datasets only, use in combination  with
              buffer option)

       -vlevel, --verboselevel
              Verbose mode if > 0

                                                 01 January 2025                                 pkextractogr(1)

Synopsis

pkextractogr-iinput [-ssample | -randnumber | -gridsize] -ooutput [options]

See Also