Thursday, 12 October 2017

Computing shortest distance to line segment from set of points using QGIS?



I have a shapefile that describes the urban boundaries of a city and I want to calculate for a set of points the nearest distance to the boundary. Given the number of points is very large (millions) I decided to first test my planned procedure to make sure it is producing the correct output. This is what I did:



  1. Created a grid of test points using 'Create grid'

  2. Converted the boundary to a set of points using 'Convert lines to points'

  3. Identified the shortest path to the boundary using 'Distance to nearest hub (lines to hub)' with meters as the measurement unit


I have encountered a problem in that for a number of test points, particularly those for which the shortest path to the boundary is in a north-south direction, the nearest point on the boundary identified by 'Distance to nearest hub' is incorrect (ie. there are other points on the boundary that are closer).


enter image description here


As an example, for the selected test point, the closest point on the boundary identified by 'Distance to nearest hub' (ie. the northern most point) is 15037.985 meters away, but in fact there is a closer point (the western most point) that is only 14679.774 meters away. I have also checked these distances (and a number of others) against Google Maps and they seem to be fairly accurate (within 10-20 meters).


Not sure what is going on here. I am relatively new to QGIS. I am using QGIS version 3.2.3-Bonn.





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...