Pan-sharpening

Pan-sharpening.

class orthority.pan_sharp.PanSharpen(pan_file, ms_file)

Bases: object

Pan-sharpener.

Increases the resolution of a multispectral image to that of a panchromatic image using the Gram-Schmidt method (https://doi.org/10.5194/isprsarchives-XL-1-W1-239-2013).

Panchromatic and multispectral image bounds should overlap if they are georeferenced. If one or both of the images are not georeferenced, they are assumed to having matching bounds.

Parameters:
  • pan_file (str | PathLike | OpenFile | rio.DatasetReader) – Panchromatic image. Can be a path or URI string, an OpenFile object in binary mode ('rb'), or a dataset reader.

  • ms_file (str | PathLike | OpenFile | rio.DatasetReader) – Multispectral image. Can be a path or URI string, an OpenFile object in binary mode ('rb'), or a dataset reader.

process(out_file, pan_index=1, ms_indexes=None, weights=None, interp=cubic, write_mask=None, dtype=None, compress=None, build_ovw=True, creation_options=None, driver=gtiff, overwrite=False, progress=False)

Pan-sharpen.

The pan-sharpened image is created on the panchromatic pixel grid. Pan-sharpened image bounds are the intersection of the panchromatic and multispectral image bounds.

Pan-sharpening consists of two steps, both of which operate tile-by-tile:

  1. Derive the Gram-Schmidt parameters from image statistics.

  2. Generate the pan-sharpened image.

Parameters:
  • out_file (str | PathLike | OpenFile) – Pan-sharpened image file to create. Can be a path or URI string, or an OpenFile object in binary mode ('wb').

  • pan_index (int) – Index of the panchromatic band to use (1-based).

  • ms_indexes (Sequence[int]) – Indexes of the multispectral bands to use (1-based). If set to None (the default), all non-alpha multispectral bands are used.

  • weights (bool | Sequence[float]) – Multi-spectral to panchromatic weights (≥0). If set to None (the default), weights are estimated from the images.

  • interp (str | Interp) – Interpolation method for upsampling the multispectral image.

  • write_mask (bool | None) – Mask valid pan-sharpened pixels with an internal mask (True), or with a nodata value based on dtype (False). An internal mask helps remove nodata noise caused by lossy compression. If set to None (the default), the mask will be written when JPEG compression is used.

  • dtype (str) – Pan-sharpened image data type (uint8, uint16, int16, float32 or float64). If set to None (the default), the source image data type is used.

  • compress (str | Compress | None) – Pan-sharpened image compression type (jpeg, deflate or lzw). deflate and lzw can be used with any dtype, and jpeg with the uint8 dtype. With supporting Rasterio builds, jpeg can also be used with uint16, in which case the ortho is 12 bit JPEG compressed. If compress is set to None (the default), jpeg is used for the uint8 dtype, and deflate otherwise.

  • build_ovw (bool) – Whether to build overviews for the pan-sharpened image.

  • creation_options (dict | None) – Pan-sharpened image creation options as dictionary of name: value pairs. If supplied, compress is ignored. See the GDAL docs for details.

  • driver (str | Driver) – Pan-sharpened image driver (gtiff or cog).

  • overwrite (bool) – Whether to overwrite the pan-sharpened image if it exists.

  • progress (bool | Sequence[dict]) – Whether to display a progress bar monitoring the portion of tiles processed in each step. Can be set to a sequence of two argument dictionaries that define a custom tqdm bar for each step.