pkcrop(1)

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

SYNOPSIS
\FCpkcrop\F[]
\FC-i\F[] input \FC-o\F[] 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[] \FC-uly\F[] \FC-lrx\F[] \FC-lry\F[]. Alternatively you can set the new image center (\FC-x\F[] \FC-y\F[]) and size. This can be done either in projected coordinates (using the options \FC-nx\F[] \FC-ny\F[]) or in image coordinates (using the options \FC-ns\F[] \FC-nl\F[]). You can also use a vector file to set the new bounding box (option \FC-e\F[]). 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[]. 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) instead.

OPTIONS

\FC-i\F[] filename, \FC--input\F[] filename
    Input image file(s). If input contains multiple images, a multi-band output is created

\FC-o\F[] filename, \FC--output\F[] filename
    Output image file

\FC-of\F[] out_format, \FC--oformat\F[] out_format
    Output image format (see also gdal_translate(1)). Empty string: inherit from input image

\FC-ot\F[] type, \FC--otype\F[] 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[] band, \FC--band\F[] band
    Band index to crop (leave empty to retain all bands)

\FC-sband\F[] band, \FC--startband\F[] band
    Start band sequence number

\FC-eband\F[] band, \FC--endband\F[] band
    End band sequence number

\FC-ulx\F[] ULX, \FC--ulx\F[] ULX
    Upper left x value bounding box

\FC-uly\F[] ULY, \FC--uly\F[] ULY
    Upper left y value bounding box

\FC-lrx\F[] LRX, \FC--lrx\F[] LRX
    Lower right x value bounding box

\FC-lry\F[] LRY, \FC--lry\F[] LRY
    Lower right y value bounding box

\FC-dx\F[] xres, \FC--dx\F[] xres
    Output resolution in x (in meter) (empty: keep original resolution)

\FC-dy\F[] yres, \FC--dy\F[] yres
    Output resolution in y (in meter) (empty: keep original resolution)

\FC-r\F[] resampling_method, \FC--resampling-method\F[] resampling_method
    Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).

\FC-a_srs\F[] EPSG:number, \FC--a_srs\F[] 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[] value, \FC--nodata\F[] value
    Nodata value to put in image if out of bounds.

Advanced options

\FC-e\F[] vector, \FC--extent\F[] vector
    get boundary from extent from polygons in vector file

\FC-cut\F[], \FC--crop_to_cutline\F[]
    Crop the extent of the target dataset to the extent of the cutline

\FC-eo\F[] options, \FC--eo\F[] options
    Special extent options controlling rasterization: \FCATTRIBUTE|CHUNKYSIZE|ALL_TOUCHED|BURN_VALUE_FROM|MERGE_ALG\F[], e.g., \FC-eo\F[] \FCATTRIBUTE=\F[]fieldname

\FC-m\F[] file, \FC--mask\F[] file
    Use the specified file as a validity mask (0 is nodata)

\FC-msknodata\F[] value, \FC--msknodata\F[] value
    Mask value not to consider for crop

\FC-mskband\F[] value, \FC--mskband\F[] value
    Mask band to read (0 indexed).

\FC-co\F[] NAME=VALUE, \FC--co\F[] NAME=VALUE
    Creation option for output file. Multiple options can be specified.

\FC-x\F[] center_x, \FC--x\F[] center_x
    x-coordinate of image center to crop (in meter)

\FC-y\F[] center_y, \FC--y\F[] center_y
    y-coordinate of image center to crop (in meter)

\FC-nx\F[] size_x, \FC--nx\F[] size_x
    image size in x to crop (in meter)

\FC-ny\F[] size_y, \FC--ny\F[] size_y
    image size in y to crop (in meter)

\FC-ns\F[] nsample, \FC--ns\F[] nsample
    number of samples to crop (in pixels)

\FC-nl\F[] nlines, \FC--nl\F[] nlines
    number of lines to crop (in pixels)

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

\FC-scale\F[] scale, \FC--scale\F[] scale
    output=scale*input+offset

\FC-off\F[] offset, \FC--offset\F[] offset
    output=scale*input+offset

\FC-ct\F[] filename, \FC--ct\F[] filename
    colour table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid)

\FC-align\F[], \FC--align\F[]
    Align output bounding box to input image

\FC-d\F[] description, \FC--description\F[] description
    Set image description

\FC-v\F[], \FC--verbose\F[]
    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[]

Crop the input image to the envelop of the given polygon and mask all pixels outside polygon as 0 (using gdal_rasterize(1))

\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[]

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

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

Scale raster floating point image \FCfimage.tif\F[] 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[]

Automatically scale raster floating point image \FCfimage.tif\F[] 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[]

Crop raster image \FClarge.tif\F[] to the bounding box of raster image \FCsmall.tif\F[] and use the same pixel size.

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

SEE ALSO
pkcomposite(1)