Open changliao1025 opened 1 month ago
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 That is exactly what I meant. Thanks for pointing out the built-in API for OGR_GreatCircle_Distance().
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.