2

As I am from an economics department, I am quite a beginner in QGIS. I read, that if I wanted to calculate the distance from a polygon to a point/line/another polygon, I should use the GRASS plugin v.distance.

Does anyone know how exactly the plugin calculates the distance? Let's say I want to know what's the minimum distance from Bavaria to the sea. Does v.distance take the center of Bavaria or does it divide the border into small points and then calculate the distance to the nearest sea spot?

1
  • 1
    Please explain "Minimum distance from Germany to the sea" ... it is 0m since Germany is at the sea :-) If you want to calculate the distance between centroid of the Germanyy polygon and the coastline, then it differs from the question "what is the minimal distance between two polygons". Please consider to edit your question. – markusN Sep 18 '15 at 10:18
3

Markus Metz, one of the GRASS developers, described in one of his posts how such features are calculated.

Here is the quote:

For lines to lines, say line A to line B, it calculates shortest distance of each vertex in A with each segment (not vertex) in B. So far, this is the same like in the original version, results are identical. Now if line A is a line or boundary, it calculates the shortest distance of each vertex in B to each segment in A. Additionally, it checks for intersections. In case of intersections, the first intersection found is used and the distance set to zero.

For lines to areas, it behaves similar to the original version. If a line is inside an area, the distance is set to zero. The first point of the line inside the area is used as common point. The distance is also set to zero if the line intersects with the outer ring or any of the inner rings (isles), in which case the fist intersection is used as common point.

For areas to areas, the module checks first for overlap or if one area is (partially) inside the other area. This is computationally quite intensive. If the outer rings of the two areas do not overlap, the distance is calculated as above for lines to lines, treating the outer rings as two lines. Again, the first point encountered falling into an area is used as common point, or the first intersection point.

For anything else than points to lines, there can be several common points with distance = zero, and the closest location could then be several points or several lines or several areas (result of overlay). For v.distance, I choose to select a single point, and not create an overlay like v.overlay.

Hope this clears it up a little!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.