pkcomposite(1) | pkcomposite(1) |
pkcomposite - program to mosaic and composite geo-referenced images
pkcomposite
-i input [-i input] -o output
[options] [advanced options]
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 -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
Advanced options
Create a composit from two input images. If images overlap, keep only last image (default rule)
pkcomposite -i input1.tif -i input2.tif -o output.tif
Create a composit from two input images. Values of 255 in band 1 (starting from 0) are masked as invalid. Typically used when second band of input image is a cloud mask
pkcomposite -i input1.tif -i input2.tif -srcnodata 255 -bndnodata 1 -dstnodata 0 -o output.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 -i input1.tif -i input2.tif -cr maxndvi -rb 0 -rb 1 -srcnodata 255 -bndnodata 0 -dstnodata 0 -o output.tif
Create a composite image using weighted mean: output=(3/4*input1+6/4*input2+3/4*input2)/3.0
pkcomposite -i input1.tif -i input2.tif -i input3.tif -o output.tif -cr mean -w 0.75 -w 1.5 -w 0.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 -i large.tif $(for IMAGE in *.tif;do pkinfo -i $IMAGE --cover $(pkinfo -i coverage.tif -bb);done) -cr median -min 0 -o output.tif
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 applied to all invalid bands
Example:
pkcomposite -i input1.tif -i input2.tif -o output.tif -srcnodata 0 -srcnodata 255 -bndnodata 0 -bndnodata 1
will consider 0 in band 0 and 255 in band 1 of input images as no value
pkcomposite -i input1.tif -i input2.tif -o output.tif -srcnodata 0 -bndnodata 0 -bndnodata 1
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 -i input1.tif -i input2.tif -o output.tif -min 0 -max 200 -min 0 -max 2 -bndnodata 0 -bndnodata 1
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 December 2022 |