4

How do I measure the distance between all points in a vector layer and a polygon (not to the polygon centroid, but to it's border line)?

In the image points are fires and the polygon is a National Park. I need to measure how far is each fire from the park's border.

enter image description here

Vince
  • 20,017
  • 15
  • 45
  • 64
h_carpio
  • 51
  • 2
  • 2
    Convert the boundary of the polygon to a line https://docs.qgis.org/2.8/en/docs/user_manual/processing_algs/qgis/vector_geometry_tools/polygonstolines.html then use point distance using v.distance https://gis.stackexchange.com/questions/108658/qgis-distance-from-points-to-nearest-line to find how far each point is from the bounding line. – Michael Stimson Oct 30 '20 at 00:14
  • Thank you very much @MichaelStimson! I was struggling to run NNJoin before, but converting the boundary of the polygon into a line was it! Thanks. – h_carpio Oct 30 '20 at 00:47

2 Answers2

5

Finding the point distance to the boundary of a polygon for points that are inside can't be done directly as the proximity tool evaluates the distance from point to polygon as 0. To find the shortest distance of a point inside a polygon to its boundary degenerate the polygon to its bounding line, this link is different to the comment and has nice pictures.

After the polygon is reduced to its bounding line the distance can be calculated with v.distance and probably using NNJoin as you say but I can't attest to that having not used the NNJoin tool (yet).

Michael Stimson
  • 25,566
  • 2
  • 35
  • 74
1

You can also use saga snap point to line (processing). That gives you the option on moving the point or producing a line. That line however will not be snapped because of float point errors but the distance will be good.