GDAL-RASTER-PROXIMITY(1)

πŸ“¦
version 3.13.3 Β· 4 versions
, in alpine 3.24, arch rolling, ubuntu stonking

πŸ’– GDAL-RASTER-PROXIMITY β€” a.k.a. the gdal raster proximity page πŸ’–

okay bestie, welcome to the GDAL manual, page GDAL-RASTER-PROXIMITY(1). Grab a snack, we're mapping distances today and it's gonna be iconic. ✨


🌸 NAME 🌸

gdal-raster-proximity β€” produces a raster proximity map πŸ—ΊοΈ

Added in version 3.12.


✨ SYNOPSIS ✨

Usage: gdal raster proximity [OPTIONS] <INPUT> <OUTPUT>

Produces a raster proximity map.

Positional arguments:
  -i, --input <INPUT>                                      Input raster datasets [required] [not available in pipelines]
  -o, --output <OUTPUT>                                    Output raster dataset [required] [not available in pipelines]

Common Options:
  -h, --help                                               Display help message and exit
  --json-usage                                             Display usage as JSON document and exit
  --config <KEY>=<VALUE>                                   Configuration option [may be repeated]
  -q, --quiet                                              Quiet mode (no progress bar or warning message) [not available in pipelines]

Options:
  -f, --of, --format, --output-format <OUTPUT-FORMAT>      Output format ("GDALG" allowed) [not available in pipelines]
  --co, --creation-option <KEY>=<VALUE>                    Creation option [may be repeated] [not available in pipelines]
  --overwrite                                              Whether overwriting existing output dataset is allowed [not available in pipelines]
                                                           Mutually exclusive with --append
  --append                                                 Append as a subdataset to existing output [not available in pipelines]
                                                           Mutually exclusive with --overwrite
  --ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE>  Output data type. OUTPUT-DATA-TYPE=UInt8|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64|Byte|UInt16|Int16|UInt32|Int32|Float32|Float64 (default: Float32)
  -b, --band <BAND>                                        Input band (1-based index)
  --target-values <TARGET-VALUES>                          Target pixel values [may be repeated]
  --distance-units <DISTANCE-UNITS>                        Distance units. DISTANCE-UNITS=pixel|geo (default: pixel)
  --max-distance <MAX-DISTANCE>                            Maximum distance. The nodata value will be used for pixels beyond this distance (default: 0)
  --fixed-value <FIXED-VALUE>                              Fixed value for the pixels that are within the maximum distance (instead of the actual distance) (default: 0)
  --nodata <NODATA>                                        Specify a nodata value to use for pixels that are beyond the maximum distance

Advanced Options:
  --if, --input-format <INPUT-FORMAT>                      Input formats [may be repeated] [not available in pipelines]
  --oo, --open-option <KEY>=<VALUE>                        Open options [may be repeated] [not available in pipelines]

Quick vibe check on the ✨vital✨ bits:

  • <INPUT> and <OUTPUT> are required, and neither of them works in pipelines. 🚫
  • --overwrite and --append are mutually exclusive β€” pick a lane, bestie, you can't do both. πŸ’€
  • the [not available in pipelines] tag keeps showing up, so clock it: input output, -f, --co, --overwrite, --append, -q, --if and --oo are all pipeline-antisocial. πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

gdal raster proximity makes you a raster proximity map πŸ’« β€” it tells you the Cartesian distance from the center of every single pixel to the center of the nearest pixel that counts as a target pixel.

And what's a target pixel, you ask? It's any pixel in the source raster whose raster pixel value is sitting in the set of target pixel values. That's it. That's the whole criteria. No cap. 🎯

This subcommand is also available as a potential step of gdal raster pipeline πŸ”—

Added in version 3.12.


🌈 GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) 🌈

This program supports serializing the command line as a JSON file using the GDALG output format πŸ“. The resulting file can then be opened as a raster dataset using the GDALG: GDAL Streamed Algorithm driver, and it'll apply the specified pipeline in an on-the-fly / streamed way. So slick. ✨

NOTE: But heads up, bestie β€” this algorithm is not natively streaming compatible 😭. So a temporary dataset will be generated, and that may cause significant processing time at opening. Budget for it, seriously.

πŸŽ€ PROGRAM-SPECIFIC OPTIONS πŸŽ€

  • -b, --band <BAND> β€” the input band, and it's a 1-based index (so the first band is 1, not 0, we don't do zero-indexing here 🫢).
  • --distance-units <pixel|geo> β€” the units for the distance 🧭. Pass geo and the distance gets calculated in georeferenced units (meters or degrees) using the pixel size of the input raster. Otherwise the distance is interpreted in pixels.
  • --fixed-value <FIXED-VALUE> β€” define a fixed value to be written to those output pixels that are within --max-distance from the target pixels, instead of the actual distance 🎯. Same value for everyone, no favorites.
  • --max-distance <MAX-DISTANCE> β€” the maximum distance to search for a target pixel πŸ”. If no target pixel is found within this distance, the NoData value gets output. Distance is interpreted in pixels unless you specified --distance-units geo.
  • --nodata <NODATA> β€” the Nodata value for the output raster. If you don't specify it, the NoData value of the input band will be used. And if the output band doesn't have a NoData value at all β€” drama β€” then the value 65535 will be used for floating point output types, and the maximum value that can be stored will be used for the integer output types. 😀
  • --target-values <TARGET-VALUES> β€” a single value or a comma separated list of target pixel values in the source image to be considered target pixels 🎯. If you don't specify it at all, then all non-zero pixels are treated as target pixels. Generous of it.

πŸ’… STANDARD OPTIONS πŸ’…

  • --append β€” append input raster as a new subdataset to an existing output file πŸ“Ž. Only works with drivers that support adding subdatasets, like GTiff -- GeoTIFF File Format and GPKG -- GeoPackage raster. This also creates the output dataset if it doesn't exist yet, so it's giving main-character initiative. πŸ‘‘
  • --co, --creation-option <NAME>=<VALUE> β€” so many formats have one or more optional creation options that control the particulars of the file being created πŸ› οΈ. For instance the GeoTIFF driver has creation options for compression, and for whether the file should be tiled. May be repeated. The creation options available vary by format driver, and some simple formats have no creation options at all. You can list what a format supports with the --formats command line option β€” but fr fr, the documentation for the format is the definitive source on driver creation options. See Raster drivers format specific documentation for the legal creation options for each format.
  • --if, --input-format <format> β€” format/driver name to attempt when opening the input file(s) πŸ“‚. It's generally not necessary to specify it, but it's handy for skipping automatic driver detection when that fails to select the appropriate driver. May be repeated several times to specify several candidate drivers. But note: it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions πŸ‘€.
  • --oo, --open-option <NAME>=<VALUE> β€” dataset open option (format specific) πŸ”“. May be repeated.
  • -f, --of, --format, --output-format <OUTPUT-FORMAT> β€” which output raster format to use 🎨. Allowed values may be given by gdal --formats | grep raster | grep rw | sort.
  • --ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE> β€” the output data type, among Byte, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, CInt16, CInt32, Float32, Float64, CFloat32, CFloat64. πŸ”’
  • --overwrite β€” allow the program to overwrite an existing target file or dataset πŸ’₯. Otherwise, by default, gdal errors out if the target file or dataset already exists. So yes, you have to ask nicely.

⭐ RETURN STATUS CODE ⭐

The program returns status code 0 in case of success βœ…, and non-zero in case of error ❌. And plot twist: non-blocking errors emitted as warnings are considered as a successful execution, so a lil warning noise doesn't tank your exit code. πŸ’…


πŸ”₯ EXAMPLES πŸ”₯

Example 1

title β€” Proximity map of a raster with max distance of 3 pixels πŸ—ΊοΈ

$ gdal raster proximity --max-distance 3  input.tif output.tif

πŸ‘‘ AUTHOR πŸ‘‘

Alessandro Pasotti <elpaso@itopen.it> πŸ’Œ


1998-2026


and that's the whole page, bestie 🫢 β€” this was the GDAL-RASTER-PROXIMITY(1) page from the GDAL manual, dated Aug 18, 2026, and it literally ate. go map some distances, no cap. πŸŽ€βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from