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 πŸ‘‘

  • -i filename, --input filename β€” the input image file. your source of truth, your main character. 🌟
  • -o filename, --output filename β€” the output mask file. this is where the magic gets written. ✨
  • -min value, --min value β€” values smaller than the min threshold(s) get masked as invalid. use one threshold for each band. πŸ‘‘
  • -max value, --max value β€” values greater than the max threshold(s) get masked as invalid. use one threshold for each band. πŸ‘‘
  • -data value, --data value β€” the value(s) for valid pixels: between min and max. these are the good ones, the ones that pass the vibe check. 🫢
  • -nodata value, --nodata value β€” the value(s) for invalid pixels: not between min and max. sorry babes, you're out. πŸ’€
  • -v level, --verbose level β€” verbose. she talks more. πŸ—£οΈ

πŸ”₯ Advanced options πŸ”₯

  • -b band, --band band β€” the band(s) used for mask. 🎚️
  • -p AND|OR, --operator AND|OR β€” Operator: [AND,OR]. you're choosing how the band conditions combine, iykyk. πŸ”€
  • -ot type, --otype type β€” data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image. 🌈
  • -of format, --oformat format β€” output image format (see also gdal_translate(1)). πŸŽ€
  • -co option, --co option β€” creation option for output file. multiple options can be specified. stack 'em up bestie. πŸ’…
  • -ct colortable, --ct colortable β€” 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 / -max values 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