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

pksetmask - program to apply mask image (set invalid values) to raster image

Description

pksetmask  sets  a mask provided with option -m to an input raster dataset.  The default operator is '='.
       Values in the input raster data where the mask has a nodata value (set with the option  -msknodata)  will
       then be set to nodata (set with -nodata).  Other operators are less than (--operator '<') and larger than
       (--operator '<').

Example

Usingasinglemask

       With a single mask you can provide as many triples (--operator, --msknodata, --nodata) as you wish.   All
       operators  work simultaneously on that mask.  Caution: the first operator that tests true will be select‐
       ed.  This is explained in the next example:

       pksetmask-iinput.tif-mmask.tif--operator='>' --msknodata0--nodata0--operator='>' --msknodata10--nodata10-ooutput.tif

       Warning: second operator will never test true as first will supersede!

       pksetmask-iinput.tif-mmask.tif--operator='>' --msknodata10--nodata10--operator='>' --msknodata0--nodata1-ooutput.tif

       OK: values above 10 will be 10, values between 0 and 10 will be 1

       Usingmultiplemasks

       With multiple masks, you can use one triple (--operator, --msknodata, --nodata)  for  each  corresponding
       mask  (following the same order of input).  If the number of triples is not equal to the number of masks,
       then only the first triple is used for all masks simultaneously

       pksetmask-iinput.tif-mmask1.tif--operator '>' --msknodata250--nodata1-mmask2.tif--operator '>' --msknodata100--nodata2-ooutput.tif

       If mask1.tif is above 250, the output will be 1.  If mask2 is above 100, the output will be 2.   If  both
       operators test true, the first will supersede (output will be 1)

       pksetmask-iinput.tif-mmask1.tif-mmask2.tif--operator '>' --msknodata250--nodata1-ooutput.tif

       If either mask1.tif or mask2.tif is above 250, the output will be 1

       Moreexamplespksetmask-iinput.tif-mmask.tif-ooutput.tif-otByte--msknodata0-nodata255

       copy  pixel  values from input.tif to output.tif, applying mask.tif, setting all values to 255 where mask
       is 0.

       pksetmask-iinput.tif-mmask.tif-ooutput.tif-otByte--msknodata1-nodata255--operator '!'

       copy values from input.tif to output.tif, but set all values to 255 if mask is not 1

       pksetmask-iinput.tif-mmask1.tif-mmask2.tif-ooutput.tif-otByte--msknodata0-nodata255

       Application of two masks.  Copy pixel values from input.tif to output.tif,  setting  all  values  to  255
       where either mask is 0.

       pksetmask-iinput.tif-mmask.tif-ooutput.tif-otByte--msknodata0--msknodata1-nodata255-nodata255

       copy  pixel  values  from input.tif to output.tif, applying single masks, setting all values to 255 where
       mask is either 0 or 1.

Faq

       Q1. I want to mask my input image (a byte image with values between 0 and 254) with a mask that only cov‐
       ers a spatial subset of the input image.  Within the spatial subset of the primary mask, all pixels  must
       be  set  to 0 where the primary mask equals 1.  Outside the spatial subset I want to set all pixel values
       to 255.

       A1. This can be done using two masks, selecting the input image as the secondary mask.  Choose  the  sec‐
       ondary operator acting on the secondary mask such that the condition is always true (e.g, < 255).

                                                 01 January 2025                                    pksetmask(1)

Name

       pksetmask - program to apply mask image (set invalid values) to raster image

Options

-ifilename, --inputfilename
              Input image

       -mmask, --maskmask
              Mask image(s)

       -msknodatavalue, --msknodatavalue
              Mask  value(s) where image has nodata.  Use one value for each mask, or multiple values for a sin‐
              gle mask.

       -ofilename, --outputfilename
              Output mask file

       -nodatavalue, --nodatavalue
              nodata value to put in image if not valid

       -vlevel, --verboselevel
              verbose

       Advanced options

       -p'<'|'='|'>', --operator'<'|'='|'>'
              Operator: < = > !.  Use operator for each -msknodata option

       -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

       -ofGDALformat, --oformatGDALformat
              Output image format (see also gdal_translate(1)).

       -cooption, --cooption
              Creation option for output file.  Multiple options can be specified.

       -ctfilename, --ctfilename
              colour table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid)

Synopsis

pksetmask-iinput-mmask [-msknodatavalue] -ooutput [options] [advancedoptions]

See Also