1.. _gdal_pansharpen:
2
3================================================================================
4gdal_pansharpen.py
5================================================================================
6
7.. only:: html
8
9    Perform a pansharpen operation.
10
11    (Since GDAL 2.1)
12
13.. Index:: gdal_pansharpen
14
15Synopsis
16--------
17
18.. code-block::
19
20    gdal_pansharpen [--help-general] pan_dataset {spectral_dataset[,band=num]}+ out_dataset
21                    [-of format] [-b band]* [-w weight_val]*
22                    [-r {nearest,bilinear,cubic,cubicspline,lanczos,average}]
23                    [-threads {ALL_CPUS|number}] [-bitdepth val] [-nodata val]
24                    [-spat_adjust {union,intersection,none,nonewithoutwarning}]
25                    [-co NAME=VALUE]* [-q]
26
27Description
28-----------
29
30The :program:`gdal_pansharpen.py` script performs a pan-sharpening operation. It
31can create a "classic" output dataset (such as GeoTIFF), or a VRT
32dataset describing the pan-sharpening operation.
33
34More details can be found in the :ref:`gdal_vrttut_pansharpen` section.
35
36.. option:: -of <format>:
37
38    Select the output format. Starting with GDAL 2.3, if not specified,
39    the format is guessed from the extension (previously was ``GTiff``). Use
40    the short format name. ``VRT`` can also be used.
41
42.. option:: -b <band>
43
44    Select band *band* from the input spectral bands for output. Bands
45    are numbered from 1 in the order spectral bands are specified.
46    Multiple **-b** switches may be used. When no -b switch is used, all
47    input spectral bands are set for output.
48
49.. option:: -w <weight_val>
50
51    Specify a weight for the computation of the pseudo panchromatic
52    value. There must be as many -w switches as input spectral bands.
53
54.. option:: -r {nearest,bilinear,cubic (default),cubicspline,lanczos,average}
55
56    Select a resampling algorithm.
57
58.. option:: -threads {ALL_CPUS,number}
59
60    Specify number of threads to use to do the resampling and
61    pan-sharpening itself. Can be an integer number or ALL_CPUS.
62
63.. option:: -bitdepth <val>
64
65    Specify the bit depth of the panchromatic and spectral bands (e.g.
66    12). If not specified, the NBITS metadata item from the panchromatic
67    band will be used if it exists.
68
69.. option:: -nodata <val>
70
71    Specify nodata value for bands. Used for the resampling and
72    pan-sharpening computation itself. If not set, deduced from the
73    input bands, provided they have a consistent setting.
74
75.. option:: -spat_adjust {union(default),intersection,none,nonewithoutwarning}
76
77    Select behavior when bands have not the same extent. See
78    *SpatialExtentAdjustment* documentation in :ref:`gdal_vrttut_pansharpen`
79
80.. include:: options/co.rst
81
82.. option:: -q
83
84    Suppress progress monitor and other non-error output.
85
86.. option:: <pan_dataset>
87
88    Dataset with panchromatic band (first band will be used).
89
90.. option:: <spectral_dataset>[,band=num]
91
92    Dataset with one or several spectral bands. If the band option is
93    not specified, all bands of the datasets are taken into account.
94    Otherwise, only the specified (num)th band. The same dataset can be
95    repeated several times.
96
97.. option:: <out_dataset>
98
99    Output dataset
100
101Bands should be in the same projection.
102
103Example
104-------
105
106With spectral bands in a single dataset :
107
108.. code-block::
109
110    gdal_pansharpen.py panchro.tif multispectral.tif pansharpened_out.tif
111
112With a few spectral bands from a single dataset, reordered :
113
114.. code-block::
115
116    gdal_pansharpen.py panchro.tif multispectral.tif,band=3 multispectral.tif,band=2 multispectral.tif,band=1 pansharpened_out.tif
117
118With spectral bands in several datasets :
119
120.. code-block::
121
122    gdal_pansharpen.py panchro.tif band1.tif band2.tif band3.tif pansharpened_out.tif
123
124Specify weights:
125
126.. code-block::
127
128    gdal_pansharpen.py -w 0.7 -w 0.2 -w 0.1 panchro.tif multispectral.tif pansharpened_out.tif
129
130Specify RGB bands from a RGBNir multispectral dataset while computing
131the pseudo panchromatic intensity on the 4 RGBNir bands:
132
133.. code-block::
134
135    gdal_pansharpen.py -b 1 -b 2 -b 3 panchro.tif rgbnir.tif pansharpened_out.tif
136