I have a problem, very similar to Calculating distance between two points with coordinates using ArcGIS Desktop where I would like to calculate the distance between two polygons (circles) with their coordinates defined by a centroid function in the field calculator.
I found some possible options to calculate the distance between them:
- with Python console: where it looks like I should do the calculation point by point
- Distance matrix - not really applicable in y case, as I have the polygons instead of points
- NNjoin plugin - it looks like some layers must be merged, I don't want that
- GRASS v.distance - I used it, but I am getting an error as you see below.
I also used the following formula:
distance(($geometry),geometry(get_feature_by_id('Area9_Poles', 1)))
as per the answer below:
but it gives me the cumulative distance from one point only.
So, the distance is calculated always from P1. If you look at the image above you will get my point. In the Distance [meters] column I need the calculation: from P1 to P2 distance (which is correct) from P2 to P3 distance, which is not correct, because it's calculated from P1 to P3 and gives 47m, whereas it is 27.
What is missing in this formula then?
How can I calculate the distance consequently from the last point instead of the very first one?
My full data attribute table is below:



join by nearest? It should do, what you're looking for. – Erik Sep 29 '20 at 10:19