GDAL_PANSHARPEN(1)

✨ GDAL_PANSHARPEN ✨ (that's the GDAL_PANSHARPEN(1) page bestie, from the GDAL manual πŸ’–)

okay so real talk, this is the glow-up page for gdal_pansharpen and it is genuinely so useful, let's get into it 🫢


🌸 NAME 🌸

gdal_pansharpen β€” do a pansharpen operation. that's it, that's the whole vibe. lowkey iconic πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

gdal_pansharpen [--help] [--help-general]
                <pan_dataset>
                <spectral_dataset>[,band=<num>] [<spectral_dataset>[,band=<num>]]...
                <out_dataset>
                [-of <format>] [-b <band>]... [-w <weight_val>]...
                [-r {nearest|bilinear|cubic|cubicspline|lanczos|average}]
                [-threads {ALL_CPUS|<number>}] [-bitdepth <val>] [-nodata <val>]
                [-spat_adjust {union|intersection|none|nonewithoutwarning}]
                [-co <NAME>=<VALUE>]... [-q]

like, look at her. she's got layers. she's got range. periodt. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so gdal_pansharpen performs a pan-sharpening operation bestie. it can make you a "classic" output dataset (think GeoTIFF, the standard girlies) or a VRT dataset that literally just describes the pan-sharpening operation instead of doing it. main character energy either way ✨

want the deep lore? it's in the Pansharpened VRT section. iykyk πŸ’œ

NOTE: 🚨 gdal_pansharpen is a Python utility, and it's only available if you have the GDAL Python bindings available. no bindings, no pansharpen. tragic but true 😭
TIP: ✨ there's an equivalent in the new "gdal" command line interface β€” go look at gdal raster pansharpen. the future is now fr fr 🌈

πŸ¦‹ OPTIONS πŸ¦‹

okay here's the whole lineup, no skips, no cuts, every single one:

  • --help β€” shows this help message and exits. bye bestie πŸ‘‹
  • --help-general β€” gives you a brief usage message for the generic GDAL commandline options and exits. it's the generic one, not this one, got it? πŸ’…
  • -of <format> β€” picks the output format. if you don't specify it, the format is guessed from the extension. use the short format name. VRT can be used here too πŸŽ€
  • -b <band> β€” selects band band from the input spectral bands for output. bands are numbered from 1 in the order the spectral bands are specified. you can stack multiple -b switches. and when you use no -b switch at all? all input spectral bands get set for output. generous queen πŸ’–
  • -w <weight_val> β€” sets a weight for computing the pseudo panchromatic value. heads up: there must be as many -w switches as there are input spectral bands. count them. count them twice. no cap βš–οΈ
  • -r {nearest|bilinear|cubic|cubicspline|lanczos|average} β€” selects the resampling algorithm. cubic is the default. she's the default for a reason ✨
  • -threads {ALL_CPUS|<number>} β€” how many threads to use for the resampling and the pan-sharpening itself. can be an integer number or ALL_CPUS. go fast, bestie πŸƒβ™€οΈπŸ’¨
  • -bitdepth <val> β€” sets the bit depth of the panchromatic and spectral bands (e.g. 12). if you don't specify it, the NBITS metadata item from the panchromatic band will be used, if it exists. conditional queen πŸ™ˆ
  • -nodata <val> β€” sets the nodata value for bands. it's used for the resampling and the pan-sharpening computation itself. if not set, it gets deduced from the input bands β€” provided they have a consistent setting. consistent or nothing, periodt πŸ’…
  • -spat_adjust {union|intersection|none|nonewithoutwarning} β€” picks the behavior when bands don't have the same extent. see the SpatialExtentAdjustment documentation in Pansharpened VRT. union is the default 🌸
  • -co <NAME>=<VALUE> β€” many formats have one or more optional creation options you can use to control particulars about the file being created. for instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled. ✨

the creation options available vary by format driver, and some simple formats have no creation options at all. you can list the options supported for a format with the --format command line option, but the documentation for the format is the definitive source of information on driver creation options. see Raster drivers format specific documentation for the legal creation options for each format. the docs are the blueprint, bestie πŸ“–

  • -q β€” suppresses the progress monitor and other non-error output. quiet luxury πŸŽ€

🧚 positional args (the ones you actually have to type) 🧚

  • <pan_dataset> β€” the dataset with the panchromatic band. the first band will be used. one band. the first one. that's the rule πŸ‘‘
  • <spectral_dataset>[,band=<num>] β€” a dataset with one or several spectral bands. if the band option isn't specified, all bands of the datasets are taken into account. otherwise, only the specified (num)th band. and yes, you can repeat the same dataset several times β€” she's flexible like that πŸ’–
  • <out_dataset> β€” the output dataset. your masterpiece goes here ✨
πŸ’€ bands should be in the same projection. if your bands are out here living in different projections, that is not a vibe, fix it first.

⭐ RETURN STATUS CODE ⭐

the program returns status code 0 in case of success, and non-zero in case of error. and ngl there's a cute little asterisk here: non-blocking errors emitted as warnings are considered as a successful execution. so a warning is not a fail, bestie, breathe 🫢


🌈 EXAMPLE 🌈

Example 1: With spectral bands in a single dataset

gdal_pansharpen panchro.tif multispectral.tif pansharpened_out.tif

Example 2: With a few spectral bands from a single dataset, reordered

gdal_pansharpen panchro.tif multispectral.tif,band=3 multispectral.tif,band=2 multispectral.tif,band=1 pansharpened_out.tif

(reordered and everything, she ate πŸ”₯)

Example 3: With spectral bands in several datasets

gdal_pansharpen panchro.tif band1.tif band2.tif band3.tif pansharpened_out.tif

Example 4: Specifying weights

gdal_pansharpen -w 0.7 -w 0.2 -w 0.1 panchro.tif multispectral.tif pansharpened_out.tif

Example 5: Specify RGB bands from a RGBNir multispectral dataset while computing the pseudo panchromatic intensity on the 4 RGBNir bands

gdal_pansharpen -b 1 -b 2 -b 3 panchro.tif rgbnir.tif pansharpened_out.tif

πŸ’œ AUTHOR πŸ’œ

Even Rouault <even.rouault@spatialys.com> β€” actual legend, we stan 🫢


1998-2026 πŸŽ€


and that's the whole page babes πŸ’– GDAL manual, GDAL_PANSHARPEN(1), dated Aug 18, 2026 β€” go pansharpen something gorgeous for me okay? mwah πŸ’…βœ¨

πŸ“¦ where this page comes from