Scroll to navigation

pkcrop(1) pkcrop(1)

NAME

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

SYNOPSIS


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

Input image file(s). If input contains multiple images, a multi-band output is created
Output image file
Output image format (see also gdal_translate(1)). Empty string: inherit from input image
Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image
Band index to crop (leave empty to retain all bands)
Start band sequence number
End band sequence number
Upper left x value bounding box
Upper left y value bounding box
Lower right x value bounding box
Lower right y value bounding box
Output resolution in x (in meter) (empty: keep original resolution)
Output resolution in y (in meter) (empty: keep original resolution)
Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).
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)
Nodata value to put in image if out of bounds.

Advanced options

get boundary from extent from polygons in vector file
Crop the extent of the target dataset to the extent of the cutline
Special extent options controlling rasterization: ATTRIBUTE|CHUNKYSIZE|ALL_TOUCHED|BURN_VALUE_FROM|MERGE_ALG, e.g., -eo ATTRIBUTE=fieldname
Use the specified file as a validity mask (0 is nodata)
Mask value not to consider for crop
Mask band to read (0 indexed).
Creation option for output file. Multiple options can be specified.
x-coordinate of image center to crop (in meter)
y-coordinate of image center to crop (in meter)
image size in x to crop (in meter)
image size in y to crop (in meter)
number of samples to crop (in pixels)
number of lines to crop (in pixels)
scale output to min and max, e.g., --autoscale 0 --autoscale 255
output=scale*input+offset
output=scale*input+offset
colour table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid)
Align output bounding box to input image
Set image description
verbose

EXAMPLE

Crop the input image to the given bounding box

pkcrop -i input.tif -ulx 100 -uly 1000 -lrx 600 -lrx 100 -o output.tif

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

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

Extract bands 3,2,1 (starting from 0) in that order from multi-band raster image input.tif

pkcrop -i input.tif -b 3 -b 2 -b 1 -o output.tif

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

pkcrop -i fimage.tif -s 100 -ot Byte -o bimage.tif -ct colortable.txt

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

pkcrop -i fimage.tif -as 0 -as 100 -ot Byte -o bimage.tif -ct colortable.txt

Crop raster image large.tif to the bounding box of raster image small.tif and use the same pixel size.

pkcrop -i large.tif $(pkinfo -i small.tif -bb -dx -dy) -o output.tif

SEE ALSO

pkcomposite(1)

06 December 2020