Reference

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

FCpkcropF[0] FC-iF[0] input FC-oF[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-ulxF[0] FC-ulyF[0] FC-lrxF[0] FC-lryF[0]. Alternatively you can set the new image center (FC-xF[0] FC-yF[0]) and size. This can be done either in projected coordinates (using the options FC-nxF[0] FC-nyF[0]) or in image coordinates (using the options FC-nsF[0] FC-nlF[0]). You can also use a vector file to set the new bounding box (option FC-eF[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-bF[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) instead.

OPTIONS

FC-iF[0] filename, FC--inputF[0] filename

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

FC-oF[0] filename, FC--outputF[0] filename

Output image file

FC-ofF[0] out_format, FC--oformatF[0] out_format

Output image format (see also gdal_translate(1)). Empty string: inherit from input image

FC-otF[0] type, FC--otypeF[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-bF[0] band, FC--bandF[0] band

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

FC-sbandF[0] band, FC--startbandF[0] band

Start band sequence number

FC-ebandF[0] band, FC--endbandF[0] band

End band sequence number

FC-ulxF[0] ULX, FC--ulxF[0] ULX

Upper left x value bounding box

FC-ulyF[0] ULY, FC--ulyF[0] ULY

Upper left y value bounding box

FC-lrxF[0] LRX, FC--lrxF[0] LRX

Lower right x value bounding box

FC-lryF[0] LRY, FC--lryF[0] LRY

Lower right y value bounding box

FC-dxF[0] xres, FC--dxF[0] xres

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

FC-dyF[0] yres, FC--dyF[0] yres

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

FC-rF[0] resampling_method, FC--resampling-methodF[0] resampling_method

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

FC-a_srsF[0] EPSG:number, FC--a_srsF[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-nodataF[0] value, FC--nodataF[0] value

Nodata value to put in image if out of bounds.

Advanced options

FC-eF[0] vector, FC--extentF[0] vector

get boundary from extent from polygons in vector file

FC-cutF[0], FC--crop_to_cutlineF[0]

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

FC-eoF[0] options, FC--eoF[0] options

Special extent options controlling rasterization: FCATTRIBUTE|CHUNKYSIZE|ALL_TOUCHED|BURN_VALUE_FROM|MERGE_ALGF[0], e.g., FC-eoF[0] FCATTRIBUTE=F[0]fieldname

FC-mF[0] file, FC--maskF[0] file

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

FC-msknodataF[0] value, FC--msknodataF[0] value

Mask value not to consider for crop

FC-mskbandF[0] value, FC--mskbandF[0] value

Mask band to read (0 indexed).

FC-coF[0] NAME=VALUE, FC--coF[0] NAME=VALUE

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

FC-xF[0] center_x, FC--xF[0] center_x

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

FC-yF[0] center_y, FC--yF[0] center_y

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

FC-nxF[0] size_x, FC--nxF[0] size_x

image size in x to crop (in meter)

FC-nyF[0] size_y, FC--nyF[0] size_y

image size in y to crop (in meter)

FC-nsF[0] nsample, FC--nsF[0] nsample

number of samples to crop (in pixels)

FC-nlF[0] nlines, FC--nlF[0] nlines

number of lines to crop (in pixels)

FC-asF[0] min FC-asF[0] max, FC--autoscaleF[0] min FC--autoscaleautoscaleF[0] max

scale output to min and max, e.g., FC--autoscaleF[0] 0 FC--autoscaleF[0] 255

FC-scaleF[0] scale, FC--scaleF[0] scale

output=scale*input+offset

FC-offF[0] offset, FC--offsetF[0] offset

output=scale*input+offset

FC-ctF[0] filename, FC--ctF[0] filename

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

FC-alignF[0], FC--alignF[0]

Align output bounding box to input image

FC-dF[0] description, FC--descriptionF[0] description

Set image description

FC-vF[0], FC--verboseF[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))

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 FCinput.tifF[0]

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

Scale raster floating point image FCfimage.tifF[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 FCfimage.tifF[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 FClarge.tifF[0] to the bounding box of raster image FCsmall.tifF[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)

History