pkcomposite - program to mosaic and composite geo-referenced images
Contents
Description
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 resolutions.
Example: Calculate the maximum NDVI composite of two multispectral input images (e.g., red is band 0 and
near infrared is band 1)
pkcomposite-iinput1.tif-iinput2.tif-ooutput.tif-crmaxndvi-cb0-cb1
Example: Calculate the minimum nadir composite of two input images, where the forth band (b=3) contains
the view zenith angle
pkcomposite-iinput1.tif-iinput2.tif-ominzenith.tif-crminband-cb3
Example: Calculate the minimum of two input images in all bands
pkcomposite-iinput1.tif-iinput2.tif-ominimum.tif-crminallbandsExample
Create a composit from two input images. If images overlap, keep only last image (default rule)
pkcomposite-iinput1.tif-iinput2.tif-ooutput.tif
Create a composit from two input images. Values of 255 in band 1 (starting from 0) are masked as in‐
valid. Typically used when second band of input image is a cloud mask
pkcomposite-iinput1.tif-iinput2.tif-srcnodata255-bndnodata1-dstnodata0-ooutput.tif
Create a maximum NDVI (normalized difference vegetation index) composit. Values of 255 in band 0 are
masked as invalid and flagged as 0 if no other valid coverage. Typically used for (e.g., MODIS) images
where red and near infrared spectral bands are stored in bands 0 and 1 respectively. In this particular
case, a value of 255 in the first input band indicates a nodata value (e.g., cloud mask is coded within
the data values).
pkcomposite-iinput1.tif-iinput2.tif-crmaxndvi-rb0-rb1-srcnodata255-bndnodata0-dstnodata0-ooutput.tif
Create a composite image using weighted mean: output=(3/4*input1+6/4*input2+3/4*input2)/3.0
pkcomposite-iinput1.tif-iinput2.tif-iinput3.tif-ooutput.tif-crmean-w0.75-w1.5-w0.75
Create a median composit of all GTiff images found in current directory that cover (at least part of) the
image coverage.tif. Values smaller or equal to 0 are set as nodata 0 (default value for -dstnodata)
pkcomposite-ilarge.tif $(for IMAGE in *.tif;do pkinfo-i $IMAGE --cover $(pkinfo-icoverage.tif-bb);done) -crmedian-min0-ooutput.tifFaq
Q1. First question
A1. For individual invalid value(s) in input image, use -srcnodata
Usage: use unique value for each invalid bands set in --bndnodata or use a single value that will be ap‐
plied to all invalid bands
Example:
pkcomposite-iinput1.tif-iinput2.tif-ooutput.tif-srcnodata0-srcnodata255-bndnodata0-bndnodata1
will consider 0 in band 0 and 255 in band 1 of input images as no value
pkcomposite-iinput1.tif-iinput2.tif-ooutput.tif-srcnodata0-bndnodata0-bndnodata1
will consider 0 in both bands 0 and 1 of input images as no value
For range(s) of invalid values in input images: use -min (--min) and -max (--max) Usage: use unique range
set for each invalid bands set in -bndnodata
Example:
pkcomposite-iinput1.tif-iinput2.tif-ooutput.tif-min0-max200-min0-max2-bndnodata0-bndnodata1
will consider all negative values in band 0 and 1 of input images as invalid. Values larger or equal to
200 in band 0 will be invalid, as well as values larger or equal to 2 in band 1
Q2. If I take the mean value as composit rule for multi-band input images, will the output image contain
the mean value of overlapping images in each band?
A2. Yes
01 January 2025 pkcomposite(1)
Name
pkcomposite - program to mosaic and composite geo-referenced images
Options
-ifilename, --inputfilename
Input image file(s). If input contains multiple images, a multi-band output is created
-ofilename, --outputfilename
Output image file
-bband, --bandband
band index(es) to crop (leave empty if all bands must be retained)
-dxxres, --dxxres
Output resolution in x (in meter) (empty: keep original resolution)
-dyyres, --dyyres
Output resolution in y (in meter) (empty: keep original resolution)
-evector, --extentvector
get boundary from extent from polygons in vector file
-cut, --crop_to_cutline
Crop the extent of the target dataset to the extent of the cutline
-eooptions, --eooptions
Special extent options controlling rasterization: ATTRIBUTE|CHUNKYSIZE|ALL_TOUCHED|BURN_VAL‐
UE_FROM|MERGE_ALG, e.g., -eo ATTRIBUTE=fieldname-mmask, --maskmask
Use the first band of the specified file as a validity mask (0 is nodata)
-msknodatavalue, --msknodatavalue
Mask value not to consider for composite
-mskbandvalue, --mskbandvalue
Mask band to read (0 indexed)
-ulxULX, --ulxULX
Upper left x value bounding box
-ulyULY, --ulyULY
Upper left y value bounding box
-lrxLRX, --lrxLRX
Lower right x value bounding box
-lryLRY, --lryLRY
Lower right y value bounding box
-crrule, --crulerule
Composite rule (overwrite, maxndvi, maxband, minband, mean, mode (only for byte images), median,
sum
-cbband, --cbband
band index used for the composite rule (e.g., for ndvi, use --cband=0--cband=1 with 0 and 1 in‐
dices for red and nir band respectively
-srcnodatavalue, --srcnodatavalue
invalid value for input image
-bndnodataband, --bndnodataband
Bands in input image to check if pixel is valid (used for srcnodata, min and max options)
-minvalue, --minvalue
flag values smaller or equal to this value as invalid.
-maxvalue, --maxvalue
flag values larger or equal to this value as invalid.
-dstnodatavalue, --dstnodatavalue
nodata value to put in output image if not valid or out of bounds.
-rresampling_method, --resampling-methodresampling_method
Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).
-ottype, --otypetype
Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 /
CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image
-ofGDALformat, --oformatGDALformat
Output image format (see also gdal_translate(1)). Empty string: inherit from input image
-coNAME=VALUE, --coNAME=VALUE
Creation option for output file. Multiple options can be specified.
-a_srsEPSG:number, --a_srsEPSG: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)
-v, --verbose
verbose
Advanced options
-file, --file
write number of observations (1) or sequence nr of selected file (2) for each pixels as additional
layer in composite. Default: 0
-wweight, --weightweight
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.
-cname, --classname
classes for multi-band output image: each band represents the number of observations for one spe‐
cific class. Use value 0 for no multi-band output image.
-ctfilename, --ctfilename
colour table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid)
-align, --align
Align output bounding box to first input image
-scalevalue, --scalevalue
Scale value output=scale*input+offset
-offvalue, --offsetvalue
Offset value output=scale*input+offset
-ddescription, --descriptiondescription
Set image description
Synopsis
pkcomposite-iinput [-iinput] -ooutput [options] [advancedoptions]
