Skip to content

Cli gdal proximity#12350

Merged
rouault merged 12 commits intoOSGeo:masterfrom
elpaso:cli-gdal-proximity
May 13, 2025
Merged

Cli gdal proximity#12350
rouault merged 12 commits intoOSGeo:masterfrom
elpaso:cli-gdal-proximity

Conversation

@elpaso
Copy link
Copy Markdown
Collaborator

@elpaso elpaso commented May 12, 2025

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

Produces a raster proximity map.

Positional arguments:
  -i, --input <INPUT>                                      Input raster dataset [required]
  -o, --output <OUTPUT>                                    Output raster dataset (created by algorithm) [required]

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]
  --progress                                               Display progress bar

Options:
  -f, --of, --format, --output-format <OUTPUT-FORMAT>      Output format
  --co, --creation-option <KEY>=<VALUE>                    Creation option [may be repeated]
  --overwrite                                              Whether overwriting existing output is allowed
  --ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE>  Output data type. OUTPUT-DATA-TYPE=Byte|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-buffer <FIXED-BUFFER>                            Fixed buffer value (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:
  --oo, --open-option <KEY>=<VALUE>                        Open options [may be repeated]
  --if, --input-format <INPUT-FORMAT>                      Input formats [may be repeated]

For more details, consult https://gdal.org/programs/gdal_raster_proximity.html

@elpaso elpaso added funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend labels May 12, 2025
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Define a fixed value to be written in the output pixels that are within the
specified maximum distance from the target pixels, instead of the actual distance.

.. option:: --nodata <NODATA>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use --dst-nodata for consistency with other commands ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all in for consistency but we have a mixed situation already. Maybe worth filing a ticket to address the nodata argument altogether (and also the NoData camel case in the docs)?

immagine

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticketed as: #12364


.. option:: --nodata <NODATA>

Nodata value for the output raster. If not specified, the nodata value of the input band will be used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the input band does not have a NoData value?

Copy link
Copy Markdown
Collaborator Author

@elpaso elpaso May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://gdal.org/en/stable/programs/gdal_proximity.html 65535 is used but let me write a few tests for that: I doubt that it will work with Byte output type.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests added and documentation expanded.

georeferenced units (meters or degrees) using the pixel size of the input raster.
Otherwise, the distance is interpreted in pixels.

.. option:: --fixed-buffer <FIXED-BUFFER>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option name isn't very clear to me (although the description is.) Would --burn be appropriate, as in gdal vector rasterize ? Or --write-value ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to change it, burn means nothing to me (besides reminding of a fire). Wouldn't perhaps --fixed-value be more appropriate to convene the meaning that we are writing a fixed value instead of the varying distance?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--fixed-value sounds good.


Nodata value for the output raster. If not specified, the nodata value of the input band will be used.

.. option:: --respect-input-nodata
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--propagate-nodata ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the argument completely.

.. option:: --fixed-buffer <FIXED-BUFFER>

Define a fixed value to be written in the output pixels that are within the
specified maximum distance from the target pixels, instead of the actual distance.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be then just fixed-value?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be then just fixed-value?

I like it!

elpaso and others added 4 commits May 13, 2025 11:06
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Co-authored-by: Dan Baston <dbaston@gmail.com>
@rouault rouault added this to the 3.12.0 milestone May 13, 2025
@rouault rouault merged commit 142e472 into OSGeo:master May 13, 2025
53 of 58 checks passed
@rouault
Copy link
Copy Markdown
Member

rouault commented May 13, 2025

follow-up: make proximity pipeline compatible done in #12375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants