For those battling the same issue in the future: I came up with a new solution, that I posted on GitHub.
TL;DR
: This is the code
https://gist.github.com/MarByteBeep/e688759bc051a59a5651e0ecd45240ff
The long read:
Based on work done by Spatial Thoughts I created a simple algorithm that iteratively created new features and stores the distance to the original feature in a BURN
field. These distances are calculated using Azimuthal Equidistant projection. These new features can then be used to create a more accurate proximity map.
Let me provide an example. Consider the following features (military objects around some local town)
Next I run the proximity script, with the following settings
Buffer Distance
specifies the distance the buffer is drawn around a feature. In this case I defined a distance of 5000 meters.
Segments
specifies how well curves are approximated. Lower is more jaggy.
Iterations
specifies how many iso-distances are generated.
Rasterize render resolution
specifies the rasterizer resolution in degrees.
You can deselect Open output file after running algorithm
of the Proximity Vector layer
, as that layer is mostly an intermediate layer. But for the sake of explaining what's going on I'll leave it switched on.
When hitting run two layers, Proximity Vector layer
and Rasterized
, are generated.
First let's focus on the Proximity Vector layer
:
When inspecting one of the structures, you can see that all rings contain different BURN
values, each representing the distance to the original feature. Obviously I could also have named the field: DISTANCE
. But whatever :)
The other layer Rasterize
is the one we're after:
When sampling this layer, the value in the band will represent the distance in meters.
Code available below as a GitHub gist. Any optimization suggestions or other ideas are more than welcome!
https://gist.github.com/MarByteBeep/e688759bc051a59a5651e0ecd45240ff
After running 'the long road' example posted in the original question with the new algorithm, I ended up with something more intuitively correct:
Best Answer
Based on your other question, you have a Basic license and so don't have access to the Near or Generate Near Table tools. But you can still do it with a Spatial Join. If your XY are just coordinates, you need to make point features out of them first. There are other questions here that cover that.
Spatial Join your points to themselves (if they're in the same layer) with a one-to-one join_operation and closest match_option. Specify a distance field name, and the output table of the join will include a column with the distance (in dataframe CRS units) from each point to its closest neighbor.