pkgetmask(1)
π pkgetmask π
okay bestie, gather round, because today we're talking about pkgetmask β a lil program from the pkgetmask(1) manual that makes a mask image based on the values in your input raster image. she's giving utility, she's giving precision, she's giving "I will tell you exactly which pixels are valid and which ones are Not It". π
β¨ SYNOPSIS β¨
pkgetmask -i input -o output [options] [advanced options]
like yes, that's the whole vibe: you give her an input, you give her an output, and then you sprinkle on whatever options your heart desires. π¦
πΈ DESCRIPTION πΈ
So here's the tea: pkgetmask creates a mask raster dataset from an input raster dataset.
Any value that's smaller than the minimum value (-min) β or larger than the maximum value (-max) β will get hit with the -nodata value in the mask. that's it, that's the whole job. invalid pixels get the nodata treatment, periodt. π
π OPTIONS π
-ifilename,--inputfilename β the input image file. your source of truth, your main character. π-ofilename,--outputfilename β the output mask file. this is where the magic gets written. β¨-minvalue,--minvalue β values smaller than the min threshold(s) get masked as invalid. use one threshold for each band. π-maxvalue,--maxvalue β values greater than the max threshold(s) get masked as invalid. use one threshold for each band. π-datavalue,--datavalue β the value(s) for valid pixels: between min and max. these are the good ones, the ones that pass the vibe check. π«Ά-nodatavalue,--nodatavalue β the value(s) for invalid pixels: not between min and max. sorry babes, you're out. π-vlevel,--verboselevel β verbose. she talks more. π£οΈ
π₯ Advanced options π₯
-bband,--bandband β the band(s) used for mask. ποΈ-pAND|OR,--operatorAND|OR β Operator:[AND,OR]. you're choosing how the band conditions combine, iykyk. π-ottype,--otypetype β data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image. π-offormat,--oformatformat β output image format (see alsogdal_translate(1)). π-cooption,--cooption β creation option for output file. multiple options can be specified. stack 'em up bestie. π-ctcolortable,--ctcolortable β color table (file with 5 columns:id R G B ALFA(0: transparent,255: solid)). aesthetic AND functional, we love that. πΈ
π¦ EXAMPLE π¦
create mask, setting all negative values to 0 (rest to 1)
pkgetmask -i input.tif -o output.tif -min 0 -nodata 0 -data 1
create mask. Mask is set to 0 (default value for -nodata) if either band 0 is not between 0 and 10 OR (default operator) band 1 is not beβtween 0 and 250. Else mask is set to 1 (default value for -data)
pkgetmask -i input.tif -o output.tif -min 0 -max 10 -max 0 -max 250 -b 0 -b 1
π a lil note for you: those threshold flags can repeat, one per band, so don't be shy with them. that's exactly what the second example is doing β the-min/-maxvalues line up band by band. π§
okay that's the whole page bestie!! go mask some rasters, you're gonna slay π β¨
this was pkgetmask from the pkgetmask(1) manual β dated 01 January 2025 β and honestly? iconic. mwah. πππ«Ά
π¦ 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