pkextractogr(1)
π NAME π
okay bestie, so this is pkextractogr(1), and she does exactly one thing but she does it so well: extract pixel values from a raster image, using a sample that can be vector or raster π
β¨ SYNOPSIS β¨
pkextractogr -i input [-s sample | -rand number | -grid size] -o output
[options]
like, that's the whole vibe in one line. -i in, -o out, and you pick how you sample in the middle π
πΈ DESCRIPTION πΈ
okay so here's the tea π pkextractogr pulls pixel values out of an input raster dataset, and it does it based on the locations you hand it in a sample file. but wait, there's more: if you don't have a sample lying around, you can also get a random sample or a systematic grid of points extracted instead. no sample? no problem. π
the sample itself can be a vector file with points or polygons. and if you're working with polygons, you've got options, bestie:
- extract the values for all raster pixels that the polygons cover, or
- extract a single value for each polygon β like the centroid, mean, median, etc.
as output, you get a brand-new copy of the vector file, with an extra attribute holding the extracted pixel value. and not just one attribute β for each raster band in the input image, a separate attribute gets created. so if your raster dataset has three bands, you get three attributes, and their names are b0, b1 and b2. cute, consistent, iconic π
a typical usage of pkextractogr is to prepare a training sample for one of the classifiers implemented in pktools. iykyk.
π Overview of the possible extraction rules π
here's the full menu, no substitutions, no skipping:
pointβ Extract all pixel values covered by the polygon (option-polygonnot set) or extract a pixel on the surface option (-polygonset).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 optionclass).proportionβ Extract proportion of class(es) within the polygon (classes must be set with the optionclass).countβ Extract count of class(es) within the polygon (classes must be set with the optionclass).percentileβ Extract percentile as defined by optionperc(e.g, 95th percentile of values covered by polygon).
π OPTIONS π
every single one of them, bestie. nothing left out, nothing merged, we're thorough in this house π
-i filename,--input filenameβ Raster input dataset containing band information-s sample,--sample sampleβ 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.-ln layer,--ln layerβ Layer name(s) in sample (leave empty to select all)-rand number,--random numberβ Create simple random sample of points. Provide number of points to generate-grid size,--grid sizeβ Create systematic grid of points. Provide cell grid size (in projected units, e.g,. m)-o filename,--output filenameβ Output sample dataset Output sample dataset (yes she said it twice, and honestly? she's right π«Ά)-c class,--class 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 tomode,proportionorcount.-t threshold,--threshold 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.-t 80 -t 60). Use value100to select all pixels for selected class(es)-perc percentile,--perc percentileβ Percentile value used for rulepercentile-f format,--f formatβ Output sample dataset format-ft fieldType,--ftype fieldTypeβ Field type (onlyRealorInteger)-lt labelType,--ltype labelTypeβ Label type:In16orString-b band,--band bandβ Band index(es) to extract. Leave empty to use all bands-sband band,--startband bandβ Start band sequence number-eband band,--endband bandβ End band sequence number-r rule,--rule ruleβ 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.-bndnodata band,--bndnodata bandβ Band(s) in input image to check if pixel is valid (used forsrcnodata)-srcnodata value,--srcnodata valueβ Invalid value(s) for input image-tp threshold,--thresholdPolygon thresholdβ (absolute) threshold for selecting samples in each polygon-buf value,--buffer valueβ 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)-v level,--verbose levelβ Verbose mode if > 0
π«Ά friendly reminder from your girl:-ronly does its thing for a vector sample, and-circis for vector point sample datasets only β use it with the buffer option, not on its own. and-cclasses are mandatory the second you pickmode,proportionorcount. you got this π
xoxo, that's the whole pkextractogr(1) page, dated 01 January 2025 π go extract something gorgeous, bestie β¨π¦πΈ
π¦ where this page comes from
- ubuntu questing: pktools 2.6.7.6+ds-6build4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms