---
name: "pkreclass"
section: "1"
platform: "linux"
package: "pktools"
version: "2.6.7.6+ds-6+b3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pkreclass"
---

# pkreclass(1)

replace pixel values in raster image

## NAME

pkreclass - replace pixel values in raster image

## SYNOPSIS

FC**pkreclass**F\[0\]  FC**-i**F\[0\] *input* \[ FC**-c**F\[0\] *from* FC**-r**F\[0\] *to* \] FC**-o**F\[0\] *output* \[*options*\]

## DESCRIPTION

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

## OPTIONS

- FC**-i**F\[0\] *filename*, FC**--input**F\[0\] *filename*

  Input image

- FC**-m**F\[0\] *mask*, FC**--mask**F\[0\] *mask*

  Mask image(s)

- FC**-msknodata**F\[0\] *value*, FC**--msknodata**F\[0\] *value*

  Mask value(s) where image has nodata. Use one value for each mask, or multiple values for a single mask.

- FC**-nodata**F\[0\] *value*, FC**--nodata**F\[0\] *value*

  nodata value to put in image if not valid (0)

- FC**-code**F\[0\] *filename*, FC**--code**F\[0\] *filename*

  Recode text file (2 columns: from to)

- FC**-c**F\[0\] *classes*, FC**--class**F\[0\] *classes*

  list of classes to reclass (in combination with reclass option)

- FC**-r**F\[0\] *classes*, FC**--reclass**F\[0\] *classes*

  list of recoded classes (in combination with class option)

- FC**-ct**F\[0\] *filename*, FC**--ct**F\[0\] *filename*

  color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid))

- FC**-o**F\[0\] *filename*, FC**--output**F\[0\] *filename*

  Output mask file

- FC**-ot**F\[0\] *type*, FC**--otype**F\[0\] *type*

  Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image

- FC**-of**F\[0\] *format*, FC**--oformat**F\[0\] *format*

  Output image format (see also [**gdal\_translate**(1)](/gdal_translate/1.md)).

- FC**-b**F\[0\] *band*, FC**--band**F\[0\] *band*

  band index(es) to replace (other bands are copied to output)

- FC**-n**F\[0\] *name*, FC**--fname**F\[0\] *name*

  field name of the shape file to be replaced default: label

- FC**-co**F\[0\] *option*, FC**--co**F\[0\] *option*

  Creation option for output file. Multiple options can be specified.

- FC**-d**F\[0\] *description*, FC**--description**F\[0\] *description*

  Set image description

- FC**-v**F\[0\] *level*, FC**--band**F\[0\] *band*

  Band index(es) to extract. Leave empty to use all bands

- FC**-v**F\[0\] *level*, FC**--verbose**F\[0\] *level*

  Verbose mode if \> 0

## EXAMPLE

```
FC
pkreclass -i input1.tif -o output.tif -c 1 -r 0 -c 2 -r 0
      F[0]
```

replace pixel values 1 and 2 with value 0

```
FC
pkreclass -i vector.shp -o output.shp -c FROM -r TO -n INFIELD
      F[0]
```

replace *FROM* with *TO* in field *INFIELD* (of type string) in vector file FC*vector.shp*F\[0\] and write to new vector FC*output.shp*F\[0\]

```
FC
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
      F[0]
```

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

```
FC
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)
      F[0]
```

same as previous but without temporary file
