gdal icon indicating copy to clipboard operation
gdal copied to clipboard

GDAL proximity accept geographic coordinates system

Open changliao1025 opened this issue 1 year ago • 2 comments

Feature description

Currently, this api only accepts projected coordinates system https://gdal.org/programs/gdal_proximity.html If running this api at large scale using WGS84, then the result maybe incorrect because distance on the latlon should be based on spherical distance such as great circle distance.

Additional context

I made an initial attempt to support this. But to avoid breaking the code base, I simply write a simple function following the existing code. The new function works but it would be more reasonable to merge them as one, see: https://github.com/changliao1025/gdal/commit/27b9590397b3685db4529f85abac921b0fce06bf

There are still room for improvement as well. For example, when the alg searches near the edges, it should automatically search the "other" side of the domain as the Earth is a sphere.

Let me know if you have interest in implementing this feature.

changliao1025 avatar Jul 24 '24 05:07 changliao1025

Note: full @changliao1025 's changeset at https://github.com/OSGeo/gdal/compare/master...changliao1025:gdal:changliao

It would be desirable to keep the current entry point, but for example extend the DISTUNITS option to accept PIXEL, GEO and METER. If DISTUNITS=METRE and the CRS of the input band is a geographic CRS, then geodesic distance would be computed. You could use the OGR_GreatCircle_Distance() function of ogr/ogr_geo_utils.h

rouault avatar Jul 24 '24 12:07 rouault

@rouault That is exactly what I meant. Thanks for pointing out the built-in API for OGR_GreatCircle_Distance().

changliao1025 avatar Jul 24 '24 15:07 changliao1025