pktools  2.6.7
Processing Kernel for geospatial data
pkcomposite

program to mosaic and composite geo-referenced images

SYNOPSIS

Usage: pkcomposite -i input [-i input]* -o output

Options: [-b band]* [-dx xres] [-dy yres] [-e vector] [-ulx ULX -uly ULY -lrx LRX -lry LRY] [-cr rule] [-cb band] [-srcnodata value] [-bndnodata band] [-min value] [-max value] [-dstnodata value] [-r resampling_method] [-ot {Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}] [-of format] [-co NAME=VALUE]* [-a_srs epsg:number]

Advanced options: [-file] [-w weight]* [-c class]* [-ct colortable] [-d description] [-align]

Description

The utility pkcomposite can be used to mosaic and composite multiple (georeferenced) raster datasets. A mosaic can merge images with different geographical extents into a single larger image. Compositing resolves the overlapping pixels according to some rule (e.g, the median of all overlapping pixels). This utility is complementary to GDAL, which currently does not support a composite step. Input datasets can have different bounding boxes and spatial resolutionsresolution.

composite rule composite output
overwrite Overwrite overlapping pixels: the latter input image on the command line overrules the previous image
maxndvi Create a maximum NDVI (normalized difference vegetation index) composite from multi-band input images. Use option -cb to set the indexes of the red and near infrared bands respectively (e.g., -cb 0 -cb 1)
maxband Select the pixel with a maximum value in the band specified by option -cb
minband Select the pixel with a minimum value in the band specified by option -cb
mean Calculate the mean (average) of overlapping pixels
stdev Calculate the standard deviation of overlapping pixels
median Calculate the median of overlapping pixels
mode Select the mode of overlapping pixels (maximum voting): use for Byte images only
sum Calculate the arithmetic sum of overlapping pixels
maxallbands For each individual band, assign the maximum value found in all overlapping pixels. Unlike maxband, output band values cannot be attributed to a single (date) pixel in the input time series
minallbands For each individual band, assign the minimum value found in all overlapping pixels. Unlike minband, output band values cannot be attributed to a single (date) pixel in the input time series

Example: Calculate the maximum NDVI composite of two multispectral input images (e.g., red is band 0 and near infrared is band 1)

pkcomposite -i input1.tif -i input2.tif -o output.tif -cr maxndvi -cb 0 -cb 1

Example: Calculate the minimum nadir composite of two input images, where the forth band (b=3) contains the view zenith angle

pkcomposite -i input1.tif -i input2.tif -o minzenith.tif -cr minband -cb 3

Example: Calculate the minimum of two input images in all bands

pkcomposite -i input1.tif -i input2.tif -o minimum.tif -cr minallbands

Options

shortlongtypedefaultdescription
i input std::string Input image file(s). If input contains multiple images, a multi-band output is created
o output std::string Output image file
b band int band index(es) to crop (leave empty if all bands must be retained)
dx dx double Output resolution in x (in meter) (empty: keep original resolution)
dy dy double Output resolution in y (in meter) (empty: keep original resolution)
e extent std::string get boundary from extent from polygons in vector file
cut crop_to_cutline bool false Crop the extent of the target dataset to the extent of the cutline
eo eo std::string special extent options controlling rasterization: ATTRIBUTE or CHUNKYSIZE or ALL_TOUCHED or BURN_VALUE_FROM or MERGE_ALG, e.g., -eo ATTRIBUTE=fieldname
m mask std::string Use the first band of the specified file as a validity mask (0 is nodata)
msknodata msknodata float 0 Mask value not to consider for composite
mskband mskband short 0 Mask band to read (0 indexed)
ulx ulx double 0 Upper left x value bounding box
uly uly double 0 Upper left y value bounding box
lrx lrx double 0 Lower right x value bounding box
lry lry double 0 Lower right y value bounding box
cr crule std::string overwrite Composite rule (overwrite, maxndvi, maxband, minband, mean, mode (only for byte images), median, sum, maxallbands, minallbands, stdev
cb cband int 0 band index used for the composite rule (e.g., for ndvi, use –cband=0 –cband=1 with 0 and 1 indices for red and nir band respectively
srcnodata srcnodata double invalid value(s) for input raster dataset
bndnodata bndnodata int 0 Band(s) in input image to check if pixel is valid (used for srcnodata, min and max options)
min min double flag values smaller or equal to this value as invalid.
max max double flag values larger or equal to this value as invalid.
dstnodata dstnodata double 0 nodata value to put in output raster dataset if not valid or out of bounds.
r resampling-method std::string near Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).
ot otype std::string Data type for output image ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). Empty string: inherit type from input image
of oformat std::string GTiff Output image format (see also gdal_translate).
co co std::string Creation option for output file. Multiple options can be specified.
a_srs a_srs std::string 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
file file short 0 write number of observations (1) or sequence nr of selected file (2) for each pixels as additional layer in composite
w weight short 1 Weights (type: short) for the composite, use one weight for each input file in same order as input files are provided). Use value 1 for equal weights.
c class short 0 classes for multi-band output image: each band represents the number of observations for one specific class. Use value 0 for no multi-band output image.
ct ct std::string color table file with 5 columns: id R G B ALFA (0: transparent, 255: solid)
align align bool Align output bounding box to first input image
scale scale double output=scale*input+offset
off offset double output=scale*input+offset
d description std::string Set image description

Examples

Some examples how to use pkcomposite can be found here

FAQ

Frequently asked questions on pkcomposite can be found here