Pan-sharpening¶
Pan-sharpening.
- class orthority.pan_sharp.PanSharpen(pan_file, ms_file)¶
Bases:
objectPan-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
OpenFileobject 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
OpenFileobject 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:
Derive the Gram-Schmidt parameters from image statistics.
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
OpenFileobject 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 ondtype(False). An internal mask helps remove nodata noise caused by lossy compression. If set toNone(the default), the mask will be written when JPEG compression is used.dtype (str) – Pan-sharpened image data type (
uint8,uint16,int16,float32orfloat64). If set toNone(the default), the source image data type is used.compress (str | Compress | None) – Pan-sharpened image compression type (
jpeg,deflateorlzw).deflateandlzwcan be used with anydtype, andjpegwith the uint8dtype. With supporting Rasterio builds,jpegcan also be used with uint16, in which case the ortho is 12 bit JPEG compressed. Ifcompressis set toNone(the default),jpegis used for the uint8dtype, anddeflateotherwise.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: valuepairs. If supplied,compressis ignored. See the GDAL docs for details.driver (str | Driver) – Pan-sharpened image driver (
gtifforcog).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.