0

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:

  1. with Python console: where it looks like I should do the calculation point by point
  2. Distance matrix - not really applicable in y case, as I have the polygons instead of points
  3. NNjoin plugin - it looks like some layers must be merged, I don't want that
  4. GRASS v.distance - I used it, but I am getting an error as you see below.

enter image description here

  1. I also used the following formula:

      distance(($geometry),geometry(get_feature_by_id('Area9_Poles', 1)))
    

as per the answer below:

https://stackoverflow.com/questions/63231575/calculate-distance-between-two-points-in-qgis-field-calculator

but it gives me the cumulative distance from one point only.

enter image description here

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:

enter image description here

4
  • Have you had a look at join by nearest? It should do, what you're looking for.
    – Erik
    Sep 29, 2020 at 10:19
  • I found sth like this: geomnearest(Area_9 Area9_Poles)
    – Geographos
    Sep 29, 2020 at 10:23
  • Yes indeed. I already attached my data attribute table, you can see. I need the distance calculation from p1 to p2, from p2 to p3 and so on, based on the geometry (XY coordinates). All elements are tagged in the fid order (1st column).
    – Geographos
    Sep 29, 2020 at 11:04
  • As per the Help please Do not use signature, taglines, or greetings in your posts. An example of a greeting is "Good morning".
    – PolyGeo
    Oct 1, 2020 at 0:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.