---
name: "pkcomposite"
section: "1"
platform: "linux"
package: "pktools"
version: "2.6.7.6+ds-6+b3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pkcomposite"
---

# pkcomposite(1)

program to mosaic and composite geo-referenced images

## NAME

pkcomposite - program to mosaic and composite geo-referenced images

## SYNOPSIS

FC**pkcomposite**F\[0\]  FC**-i**F\[0\] *input* \[FC**-i**F\[0\] *input*\] FC**-o**F\[0\] *output* \[*options*\] \[*advanced options*\]

## 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)

```
FC
pkcomposite -i input1.tif -i input2.tif -o output.tif -cr maxndvi -cb 0 -cb 1
      F[0]
```

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

```
FC
pkcomposite -i input1.tif -i input2.tif -o minzenith.tif -cr minband -cb 3
      F[0]
```

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

```
FC
pkcomposite -i input1.tif -i input2.tif -o minimum.tif -cr minallbands
      F[0]
```

## OPTIONS

- FC**-i**F\[0\] *filename*, FC**--input**F\[0\] *filename*

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

- FC**-o**F\[0\] *filename*, FC**--output**F\[0\] *filename*

  Output image file

- FC**-b**F\[0\] *band*, FC**--band**F\[0\] *band*

  band index(es) to crop (leave empty if all bands must be retained)

- FC**-dx**F\[0\] *xres*, FC**--dx**F\[0\] *xres*

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

- FC**-dy**F\[0\] *yres*, FC**--dy**F\[0\] *yres*

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

- FC**-e**F\[0\] *vector*, FC**--extent**F\[0\] *vector*

  get boundary from extent from polygons in vector file

- FC**-cut**F\[0\], FC**--crop\_to\_cutline**F\[0\]

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

- FC**-eo**F\[0\] *options*, FC**--eo**F\[0\] *options*

  Special extent options controlling rasterization: FCATTRIBUTE\|CHUNKYSIZE\|ALL\_TOUCHED\|BURN\_VALUE\_FROM\|MERGE\_ALGF\[0\], e.g., FC**-eo**F\[0\] FCATTRIBUTE=F\[0\]*fieldname*

- FC**-m**F\[0\] *mask*, FC**--mask**F\[0\] *mask*

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

- FC**-msknodata**F\[0\] *value*, FC**--msknodata**F\[0\] *value*

  Mask value not to consider for composite

- FC**-mskband**F\[0\] *value*, FC**--mskband**F\[0\] *value*

  Mask band to read (0 indexed)

- FC**-ulx**F\[0\] *ULX*, FC**--ulx**F\[0\] *ULX*

  Upper left x value bounding box

- FC**-uly**F\[0\] *ULY*, FC**--uly**F\[0\] *ULY*

  Upper left y value bounding box

- FC**-lrx**F\[0\] *LRX*, FC**--lrx**F\[0\] *LRX*

  Lower right x value bounding box

- FC**-lry**F\[0\] *LRY*, FC**--lry**F\[0\] *LRY*

  Lower right y value bounding box

- FC**-cr**F\[0\] *rule*, FC**--crule**F\[0\] *rule*

  Composite rule (overwrite, maxndvi, maxband, minband, mean, mode (only for byte images), median, sum

- FC**-cb**F\[0\] *band*, FC**--cb**F\[0\] *band*

  band index used for the composite rule (e.g., for ndvi, use FC**--cband=0**F\[0\] FC**--cband=1**F\[0\] with 0 and 1 indices for red and nir band respectively

- FC**-srcnodata**F\[0\] *value*, FC**--srcnodata**F\[0\] *value*

  invalid value for input image

- FC**-bndnodata**F\[0\] *band*, FC**--bndnodata**F\[0\] *band*

  Bands in input image to check if pixel is valid (used for srcnodata, min and max options)

- FC**-min**F\[0\] *value*, FC**--min**F\[0\] *value*

  flag values smaller or equal to this value as invalid.

- FC**-max**F\[0\] *value*, FC**--max**F\[0\] *value*

  flag values larger or equal to this value as invalid.

- FC**-dstnodata**F\[0\] *value*, FC**--dstnodata**F\[0\] *value*

  nodata value to put in output image if not valid or out of bounds.

- FC**-r**F\[0\] *resampling\_method*, FC**--resampling-method**F\[0\] *resampling\_method*

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

- FC**-ot**F\[0\] *type*, FC**--otype**F\[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**-of**F\[0\] *GDALformat*, FC**--oformat**F\[0\] *GDALformat*

  Output image format (see also [**gdal\_translate**(1)](/gdal_translate/1.md)). Empty string: inherit from input image

- FC**-co**F\[0\] *NAME=VALUE*, FC**--co**F\[0\] *NAME=VALUE*

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

- FC**-a\_srs**F\[0\] *EPSG:number*, FC**--a\_srs**F\[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**-v**F\[0\], FC**--verbose**F\[0\]

  verbose

Advanced options

- FC**-file**F\[0\], FC**--file**F\[0\]

  write number of observations (1) or sequence nr of selected file (2) for each pixels as additional layer in composite. Default: 0

- FC**-w**F\[0\] *weight*, FC**--weight**F\[0\] *weight*

  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.

- FC**-c**F\[0\] *name*, FC**--class**F\[0\] *name*

  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.

- FC**-ct**F\[0\] *filename*, FC**--ct**F\[0\] *filename*

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

- FC**-align**F\[0\], FC**--align**F\[0\]

  Align output bounding box to first input image

- FC**-scale**F\[0\] *value*, FC**--scale**F\[0\] *value*

  Scale value FCoutput=scale\*input+offsetF\[0\]

- FC**-off**F\[0\] *value*, FC**--offset**F\[0\] *value*

  Offset value FCoutput=scale\*input+offsetF\[0\]

- FC**-d**F\[0\] *description*, FC**--description**F\[0\] *description*

  Set image description

## EXAMPLE

Create a composit from two input images. If images overlap, keep only last image (default rule)

```
FC
pkcomposite -i input1.tif -i input2.tif -o output.tif
      F[0]
```

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

```
FC
pkcomposite -i input1.tif -i input2.tif -srcnodata 255 -bndnodata 1 -dstnodata 0 -o output.tif
      F[0]
```

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).

```
FC
pkcomposite -i input1.tif -i input2.tif -cr maxndvi -rb 0 -rb 1 -srcnodata 255 -bndnodata 0 -dstnodata 0 -o output.tif
      F[0]
```

Create a composite image using weighted mean: output=(3/4\*input1+6/4\*input2+3/4\*input2)/3.0

```
FC
pkcomposite -i input1.tif -i input2.tif -i input3.tif -o output.tif -cr mean -w 0.75 -w 1.5 -w 0.75
      F[0]
```

Create a median composit of all GTiff images found in current directory that cover (at least part of) the image FC*coverage.tif*F\[0\]. Values smaller or equal to 0 are set as nodata 0 (default value for FC**-dstnodata**F\[0\])

```
FC
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
      F[0]
```

## FAQ

Q1. First question

A1. For individual invalid value(s) in input image, use FC**-srcnodata**F\[0\]

Usage: use unique value for each invalid bands set in FC**--bndnodata**F\[0\] or use a single value that will be applied to all invalid bands

Example:

```
FC
pkcomposite -i input1.tif -i input2.tif -o output.tif -srcnodata 0 -srcnodata 255 -bndnodata 0 -bndnodata 1
      F[0]
```

will consider 0 in band 0 and 255 in band 1 of input images as no value

```
FC
pkcomposite -i input1.tif -i input2.tif -o output.tif -srcnodata 0 -bndnodata 0 -bndnodata 1
      F[0]
```

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 FC**-min**F\[0\] (FC**--min**F\[0\]) and FC**-max**F\[0\] (FC**--max**F\[0\]) Usage: use unique range set for each invalid bands set in FC**-bndnodata**F\[0\]

Example:

```
FC
pkcomposite -i input1.tif -i input2.tif -o output.tif -min 0 -max 200 -min 0 -max 2 -bndnodata 0 -bndnodata 1
      F[0]
```

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
