DOKK / manpages / debian 11 / pktools / pkreclass.1.en
pkreclass(1) pkreclass(1)

pkreclass - replace pixel values in raster image


pkreclass
-i input [ -c from -r to ] -o output [options]

pkreclass is a program to replace pixel values in raster images.

Input image
Mask image(s)
Mask value(s) where image has nodata. Use one value for each mask, or multiple values for a single mask.
nodata value to put in image if not valid (0)
Recode text file (2 columns: from to)
list of classes to reclass (in combination with reclass option)
list of recoded classes (in combination with class option)
color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid))
Output mask file
Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image
Output image format (see also gdal_translate(1)).
band index(es) to replace (other bands are copied to output)
field name of the shape file to be replaced default: label
Creation option for output file. Multiple options can be specified.
Set image description
Band index(es) to extract. Leave empty to use all bands
Verbose mode if > 0

pkreclass -i input1.tif -o output.tif -c 1 -r 0 -c 2 -r 0

replace pixel values 1 and 2 with value 0

pkreclass -i vector.shp -o output.shp -c FROM -r TO -n INFIELD

replace FROM with TO in field INFIELD (of type string) in vector file vector.shp and write to new vector output.shp

for((i=0;i<256;++i));do if(($i<100));then echo "$i 1";else echo "$i 0";fi;done > code.txt; pkreclass -i input1.tif -o output.tif --code code.txt

replace all values smaller than 100 with 1, all other values with 0

pkreclass -i input1.tif -o output.tif $(for((i=0;i<256;++i));do if(($i<100));then echo -n " -c $i " " -r 1";else echo " -c $i " " -r 0";fi;done)

same as previous but without temporary file

06 December 2020