---
name: "pkcrop"
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/pkcrop"
---

# pkcrop(1)

perform raster data operations on image such as crop, extract and stack bands

## NAME

pkcrop - perform raster data operations on image such as crop, extract and stack bands

## SYNOPSIS

FC**pkcrop**F\[0\]  FC**-i**F\[0\] *input* FC**-o**F\[0\] *output* \[*options*\] \[*advanced options*\]

## DESCRIPTION

**pkcrop** can subset and stack raster images. In the spatial domain it can crop a bounding box from a larger image. The output bounding box is selected by setting the new corner coordinates using the options FC**-ulx**F\[0\] FC**-uly**F\[0\] FC**-lrx**F\[0\] FC**-lry**F\[0\]. Alternatively you can set the new image center (FC**-x**F\[0\] FC**-y**F\[0\]) and size. This can be done either in projected coordinates (using the options FC**-nx**F\[0\] FC**-ny**F\[0\]) or in image coordinates (using the options FC**-ns**F\[0\] FC**-nl**F\[0\]). You can also use a vector file to set the new bounding box (option FC**-e**F\[0\]). In the spectral domain, **pkcrop** allows you to select individual bands from one or more input image(s). Bands are stored in the same order as provided on the command line, using the option FC**-b**F\[0\]. Band numbers start with index 0 (indicating the first band). The default is to select all input bands. If more input images are provided, the bands are stacked into a multi-band image. If the bounding boxes or spatial resolution are not identical for all input images, you should explicitly set them via the options. The **pkcrop** utility is not suitable to mosaic or composite images. Consider the utility [**pkcomposite**(1)](/pkcomposite/1.md) instead.

## OPTIONS

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

  Input image file(s). If input contains multiple images, a multi-band output is created

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

  Output image file

- FC**-of**F\[0\] *out\_format*, FC**--oformat**F\[0\] *out\_format*

  Output image format (see also [**gdal\_translate**(1)](/gdal_translate/1.md)). Empty string: inherit from input image

- 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**-b**F\[0\] *band*, FC**--band**F\[0\] *band*

  Band index to crop (leave empty to retain all bands)

- FC**-sband**F\[0\] *band*, FC**--startband**F\[0\] *band*

  Start band sequence number

- FC**-eband**F\[0\] *band*, FC**--endband**F\[0\] *band*

  End band sequence number

- FC**-ulx**F\[0\] *ULX*, FC**--ulx**F\[0\] *ULX*

  Upper left x value bounding box

- FC**-uly**F\[0\] *ULY*, FC**--uly**F\[0\] *ULY*

  Upper left y value bounding box

- FC**-lrx**F\[0\] *LRX*, FC**--lrx**F\[0\] *LRX*

  Lower right x value bounding box

- FC**-lry**F\[0\] *LRY*, FC**--lry**F\[0\] *LRY*

  Lower right y value bounding box

- FC**-dx**F\[0\] *xres*, FC**--dx**F\[0\] *xres*

  Output resolution in x (in meter) (empty: keep original resolution)

- FC**-dy**F\[0\] *yres*, FC**--dy**F\[0\] *yres*

  Output resolution in y (in meter) (empty: keep original resolution)

- FC**-r**F\[0\] *resampling\_method*, FC**--resampling-method**F\[0\] *resampling\_method*

  Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).

- FC**-a\_srs**F\[0\] *EPSG:number*, FC**--a\_srs**F\[0\] *EPSG:number*

  Override the spatial reference for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid)

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

  Nodata value to put in image if out of bounds.

Advanced options

- FC**-e**F\[0\] *vector*, FC**--extent**F\[0\] *vector*

  get boundary from extent from polygons in vector file

- FC**-cut**F\[0\], FC**--crop\_to\_cutline**F\[0\]

  Crop the extent of the target dataset to the extent of the cutline

- FC**-eo**F\[0\] *options*, FC**--eo**F\[0\] *options*

  Special extent options controlling rasterization: FCATTRIBUTE\|CHUNKYSIZE\|ALL\_TOUCHED\|BURN\_VALUE\_FROM\|MERGE\_ALGF\[0\], e.g., FC**-eo**F\[0\] FCATTRIBUTE=F\[0\]*fieldname*

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

  Use the specified file as a validity mask (0 is nodata)

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

  Mask value not to consider for crop

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

  Mask band to read (0 indexed).

- FC**-co**F\[0\] *NAME=VALUE*, FC**--co**F\[0\] *NAME=VALUE*

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

- FC**-x**F\[0\] *center\_x*, FC**--x**F\[0\] *center\_x*

  x-coordinate of image center to crop (in meter)

- FC**-y**F\[0\] *center\_y*, FC**--y**F\[0\] *center\_y*

  y-coordinate of image center to crop (in meter)

- FC**-nx**F\[0\] *size\_x*, FC**--nx**F\[0\] *size\_x*

  image size in x to crop (in meter)

- FC**-ny**F\[0\] *size\_y*, FC**--ny**F\[0\] *size\_y*

  image size in y to crop (in meter)

- FC**-ns**F\[0\] *nsample*, FC**--ns**F\[0\] *nsample*

  number of samples to crop (in pixels)

- FC**-nl**F\[0\] *nlines*, FC**--nl**F\[0\] *nlines*

  number of lines to crop (in pixels)

- FC**-as**F\[0\] *min* FC**-as**F\[0\] *max*, FC**--autoscale**F\[0\] *min* FC**--autoscaleautoscale**F\[0\] *max*

  scale output to min and max, e.g., FC**--autoscale**F\[0\] *0* FC**--autoscale**F\[0\] *255*

- FC**-scale**F\[0\] *scale*, FC**--scale**F\[0\] *scale*

  output=scale\*input+offset

- FC**-off**F\[0\] *offset*, FC**--offset**F\[0\] *offset*

  output=scale\*input+offset

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

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

- FC**-align**F\[0\], FC**--align**F\[0\]

  Align output bounding box to input image

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

  Set image description

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

  verbose

## EXAMPLE

Crop the input image to the given bounding box

```
FC
pkcrop -i input.tif -ulx 100 -uly 1000 -lrx 600 -lrx 100 -o output.tif
      F[0]
```

Crop the input image to the envelop of the given polygon and mask all pixels outside polygon as 0 (using [**gdal\_rasterize**(1)](/gdal_rasterize/1.md))

```
FC
pkcrop -i input.tif -e extent.shp -o output.tif
gdal_rasterize -i -burn 0 -l extent extent.shp output.tif
gdal_rasterize -i -burn 0 -l extent extent.shp output.tif
      F[0]
```

Extract bands 3,2,1 (starting from 0) in that order from multi-band raster image FC*input.tif*F\[0\]

```
FC
pkcrop -i input.tif -b 3 -b 2 -b 1 -o output.tif
      F[0]
```

Scale raster floating point image FC*fimage.tif*F\[0\] with factor 100 and write as single byte image with the given colourtable (for auto scaling, see next example)

```
FC
pkcrop -i fimage.tif -s 100 -ot Byte -o bimage.tif -ct colortable.txt
      F[0]
```

Automatically scale raster floating point image FC*fimage.tif*F\[0\] to \[0:100\] and write the output as a single byte image with the given colourtable

```
FC
pkcrop -i fimage.tif -as 0 -as 100 -ot Byte -o bimage.tif -ct colortable.txt
      F[0]
```

Crop raster image FC*large.tif*F\[0\] to the bounding box of raster image FC*small.tif*F\[0\] and use the same pixel size.

```
FC
pkcrop -i large.tif $(pkinfo -i small.tif -bb -dx -dy) -o output.tif
      F[0]
```

## SEE ALSO

[**pkcomposite**(1)](/pkcomposite/1.md)
