'\" t -*- coding: us-ascii -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH pkextractogr 1 "14 June 2016" "" "" .SH NAME pkextractogr \- extract pixel values from raster image from a (vector or raster) sample .SH SYNOPSIS 'nh .fi .ad l \fBpkextractogr\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu \fB-i\fR \fIinput\fR [\fB-s\fR \fIsample\fR | \fB-rand\fR \fInumber\fR | \fB-grid\fR \fIsize\fR] \fB-o\fR \fIoutput\fR [\fIoptions\fR] 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION \fBpkextractogr\fR 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). .PP A typical usage of \fBpkextractogr\fR is to prepare a training sample for one of the classifiers implemented in pktools. .PP Overview of the possible extraction rules: .TS l l. T{ Extraction rule T} T{ Output features T} .T& l l. T{ point T} T{ Extract all pixel values covered by the polygon (option \*(T<\fB\-polygon\fR\*(T> not set) or extract a pixel on the surface option (\*(T<\fB\-polygon\fR\*(T> set). T} T{ allpoints T} T{ Extract all pixel values covered by the polygon. T} T{ centroid T} T{ Extract pixel value at the centroid of the polygon. T} T{ mean T} T{ Extract average of all pixel values within the polygon. T} T{ stdev T} T{ Extract standard deviation of all pixel values within the polygon. T} T{ median T} T{ Extract median of all pixel values within the polygon. T} T{ min T} T{ Extract minimum value of all pixels within the polygon. T} T{ max T} T{ Extract maximum value of all pixels within the polygon. T} T{ sum T} T{ Extract sum of the values of all pixels within the polygon. T} T{ mode T} T{ Extract the mode of classes within the polygon (classes must be set with the option class). T} T{ proportion T} T{ Extract proportion of class(es) within the polygon (classes must be set with the option class). T} T{ count T} T{ Extract count of class(es) within the polygon (classes must be set with the option class). T} T{ percentile T} T{ Extract percentile as defined by option perc (e.g, 95th percentile of values covered by polygon). T} .TE .SH OPTIONS .TP \*(T<\fB\-i\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-input\fR\*(T> \fIfilename\fR Raster input dataset containing band information .TP \*(T<\fB\-s\fR\*(T> \fIsample\fR, \*(T<\fB\-\-sample\fR\*(T> \fIsample\fR 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. .TP \*(T<\fB\-ln\fR\*(T> \fIlayer\fR, \*(T<\fB\-\-ln\fR\*(T> \fIlayer\fR Layer name(s) in sample (leave empty to select all) .TP \*(T<\fB\-rand\fR\*(T> \fInumber\fR, \*(T<\fB\-\-random\fR\*(T> \fInumber\fR Create simple random sample of points. Provide number of points to generate .TP \*(T<\fB\-grid\fR\*(T> \fIsize\fR, \*(T<\fB\-\-grid\fR\*(T> \fIsize\fR Create systematic grid of points. Provide cell grid size (in projected units, e.g,. m) .TP \*(T<\fB\-o\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-output\fR\*(T> \fIfilename\fR Output sample dataset Output sample dataset .TP \*(T<\fB\-c\fR\*(T> \fIclass\fR, \*(T<\fB\-\-class\fR\*(T> \fIclass\fR 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. .TP \*(T<\fB\-t\fR\*(T> \fIthreshold\fR, \*(T<\fB\-\-threshold\fR\*(T> \fIthreshold\fR 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. \*(T<\fB\-t\fR\*(T> \fI80\fR \*(T<\fB\-t\fR\*(T> \fI60\fR). Use value 100 to select all pixels for selected class(es) .TP \*(T<\fB\-perc\fR\*(T> \fIpercentile\fR, \*(T<\fB\-\-perc\fR\*(T> \fIpercentile\fR Percentile value used for rule percentile .TP \*(T<\fB\-f\fR\*(T> \fIformat\fR, \*(T<\fB\-\-f\fR\*(T> \fIformat\fR Output sample dataset format .TP \*(T<\fB\-ft\fR\*(T> \fIfieldType\fR, \*(T<\fB\-\-ftype\fR\*(T> \fIfieldType\fR Field type (only Real or Integer) .TP \*(T<\fB\-lt\fR\*(T> \fIlabelType\fR, \*(T<\fB\-\-ltype\fR\*(T> \fIlabelType\fR Label type: In16 or String .TP \*(T<\fB\-b\fR\*(T> \fIband\fR, \*(T<\fB\-\-band\fR\*(T> \fIband\fR Band index(es) to extract. Leave empty to use all bands .TP \*(T<\fB\-sband\fR\*(T> \fIband\fR, \*(T<\fB\-\-startband\fR\*(T> \fIband\fR Start band sequence number .TP \*(T<\fB\-eband\fR\*(T> \fIband\fR, \*(T<\fB\-\-endband\fR\*(T> \fIband\fR End band sequence number .TP \*(T<\fB\-r\fR\*(T> \fIrule\fR, \*(T<\fB\-\-rule\fR\*(T> \fIrule\fR 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. .TP \*(T<\fB\-bndnodata\fR\*(T> \fIband\fR, \*(T<\fB\-\-bndnodata\fR\*(T> \fIband\fR Band(s) in input image to check if pixel is valid (used for srcnodata) .TP \*(T<\fB\-srcnodata\fR\*(T> \fIvalue\fR, \*(T<\fB\-\-srcnodata\fR\*(T> \fIvalue\fR Invalid value(s) for input image .TP \*(T<\fB\-tp\fR\*(T> \fIthreshold\fR, \*(T<\fB\-\-thresholdPolygon\fR\*(T> \fIthreshold\fR (absolute) threshold for selecting samples in each polygon .TP \*(T<\fB\-buf\fR\*(T> \fIvalue\fR, \*(T<\fB\-\-buffer\fR\*(T> \fIvalue\fR Buffer for calculating statistics for point features .TP \*(T<\fB\-circ\fR\*(T>, \*(T<\fB\-\-circular\fR\*(T> Use a circular disc kernel buffer (for vector point sample datasets only, use in combination with buffer option) .TP \*(T<\fB\-v\fR\*(T> \fIlevel\fR, \*(T<\fB\-\-verbose\fR\*(T> \fIlevel\fR Verbose mode if > 0