'\" -*- coding: UTF-8 -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH pkreclass 1 "06 December 2020" "" "" .SH NAME pkreclass \- replace pixel values in raster image .SH SYNOPSIS 'nh .fi .ad l \fBpkreclass\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu \fB-i\fR \fIinput\fR [ \fB-c\fR \fIfrom\fR \fB-r\fR \fIto\fR ] \fB-o\fR \fIoutput\fR [\fIoptions\fR] 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION \fBpkreclass\fR is a program to replace pixel values in raster images. .SH OPTIONS .TP \*(T<\fB\-i\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-input\fR\*(T> \fIfilename\fR Input image .TP \*(T<\fB\-m\fR\*(T> \fImask\fR, \*(T<\fB\-\-mask\fR\*(T> \fImask\fR Mask image(s) .TP \*(T<\fB\-msknodata\fR\*(T> \fIvalue\fR, \*(T<\fB\-\-msknodata\fR\*(T> \fIvalue\fR Mask value(s) where image has nodata. Use one value for each mask, or multiple values for a single mask. .TP \*(T<\fB\-nodata\fR\*(T> \fIvalue\fR, \*(T<\fB\-\-nodata\fR\*(T> \fIvalue\fR nodata value to put in image if not valid (0) .TP \*(T<\fB\-code\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-code\fR\*(T> \fIfilename\fR Recode text file (2 columns: from to) .TP \*(T<\fB\-c\fR\*(T> \fIclasses\fR, \*(T<\fB\-\-class\fR\*(T> \fIclasses\fR list of classes to reclass (in combination with reclass option) .TP \*(T<\fB\-r\fR\*(T> \fIclasses\fR, \*(T<\fB\-\-reclass\fR\*(T> \fIclasses\fR list of recoded classes (in combination with class option) .TP \*(T<\fB\-ct\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-ct\fR\*(T> \fIfilename\fR color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)) .TP \*(T<\fB\-o\fR\*(T> \fIfilename\fR, \*(T<\fB\-\-output\fR\*(T> \fIfilename\fR Output mask file .TP \*(T<\fB\-ot\fR\*(T> \fItype\fR, \*(T<\fB\-\-otype\fR\*(T> \fItype\fR Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image .TP \*(T<\fB\-of\fR\*(T> \fIformat\fR, \*(T<\fB\-\-oformat\fR\*(T> \fIformat\fR Output image format (see also \fBgdal_translate\fR(1)). .TP \*(T<\fB\-b\fR\*(T> \fIband\fR, \*(T<\fB\-\-band\fR\*(T> \fIband\fR band index(es) to replace (other bands are copied to output) .TP \*(T<\fB\-n\fR\*(T> \fIname\fR, \*(T<\fB\-\-fname\fR\*(T> \fIname\fR field name of the shape file to be replaced default: label .TP \*(T<\fB\-co\fR\*(T> \fIoption\fR, \*(T<\fB\-\-co\fR\*(T> \fIoption\fR Creation option for output file. Multiple options can be specified. .TP \*(T<\fB\-d\fR\*(T> \fIdescription\fR, \*(T<\fB\-\-description\fR\*(T> \fIdescription\fR Set image description .TP \*(T<\fB\-v\fR\*(T> \fIlevel\fR, \*(T<\fB\-\-band\fR\*(T> \fIband\fR Band index(es) to extract. Leave empty to use all bands .TP \*(T<\fB\-v\fR\*(T> \fIlevel\fR, \*(T<\fB\-\-verbose\fR\*(T> \fIlevel\fR Verbose mode if > 0 .SH EXAMPLE .nf \*(T< \fBpkreclass\fR \fB\-i\fR \fIinput1.tif\fR \fB\-o\fR \fIoutput.tif\fR \fB\-c\fR \fI1\fR \fB\-r\fR \fI0\fR \fB\-c\fR \fI2\fR \fB\-r\fR \fI0\fR \*(T> .fi .PP replace pixel values 1 and 2 with value 0 .PP .nf \*(T< \fBpkreclass\fR \fB\-i\fR \fIvector.shp\fR \fB\-o\fR \fIoutput.shp\fR \fB\-c\fR \fIFROM\fR \fB\-r\fR \fITO\fR \fB\-n\fR \fIINFIELD\fR \*(T> .fi .PP replace \fIFROM\fR with \fITO\fR in field \fIINFIELD\fR (of type string) in vector file \*(T<\fIvector.shp\fR\*(T> and write to new vector \*(T<\fIoutput.shp\fR\*(T> .PP .nf \*(T< for((i=0;i<256;++i));do if(($i<100));then echo "$i 1";else echo "$i 0";fi;done > \fIcode.txt\fR; \fBpkreclass\fR \fB\-i\fR \fIinput1.tif\fR \fB\-o\fR \fIoutput.tif\fR \fB\-\-code\fR \fIcode.txt\fR \*(T> .fi .PP replace all values smaller than 100 with 1, all other values with 0 .PP .nf \*(T< \fBpkreclass\fR \fB\-i\fR \fIinput1.tif\fR \fB\-o\fR \fIoutput.tif\fR $(for((i=0;i<256;++i));do if(($i<100));then echo \fB\-n\fR " \fB\-c\fR $i " " \fB\-r\fR 1";else echo " \fB\-c\fR $i " " \fB\-r\fR 0";fi;done) \*(T> .fi .PP same as previous but without temporary file