GDAL-RASTER-PROXIMITY(1)
π 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. π«--overwriteand--appendare 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,--ifand--ooare 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 is1, not0, we don't do zero-indexing here π«Ά).--distance-units<pixel|geo>β the units for the distance π§. Passgeoand 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-distancefrom 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 value65535will 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, likeGTiff -- GeoTIFF File FormatandGPKG -- 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--formatscommand 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 bygdal --formats | grep raster | grep rw | sort.--ot,--datatype,--output-data-type<OUTPUT-DATA-TYPE>β the output data type, amongByte,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,gdalerrors 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> π
π COPYRIGHT π
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
- alpine 3.24: gdal-doc 3.13.3-r0 Β· MIT
- arch rolling: gdal 3.13.3-6 Β· MIT
- ubuntu stonking: gdal-bin 3.13.3+dfsg-1ubuntu4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms