I have 2 shapefiles - one is a series of points, the other is a polyline. I want to draw a straight line between each point to the nearest point on the polyline.
This question has already been asked with regards to ArcGIS. The solution provided by Jeff Berry looks to be exactly what I need:
Creating a line (closest vertex to line)
Unfortunately, I have never worked with python, and have only a basic understanding of coding through Linux.
My questions:
- Is anyone willing and able to modify Jeff Berry's solution to fit QGIS?
- Or is there an alternative way to create a line between points and polyline, hence avoiding python?*
*NOTE: A useful suggestion is provided here:
QGIS: creating lines from starting to arrival points?
However I've not been able to identify the coordinates of the nearest neighbor - if anyone knows how to do this, I can proceed using the non-python solution.
processing.runalg('qgis:distancetonearesthub', "/User/Ladd...etc..shp","/User/Ladd/...etc...shp","id",1,0,"/User/etc...shp")
Error read: Traceback (most recent call last): File "", line 1, in
NameError: name 'processing' is not defined
Is this because I need to install a plugin first to work? The documentation website has no extra information on using the command!
– Cai Ladd Jun 10 '15 at 16:42import processingfirst and then call the algorithm. I've edited my post. – Joseph Jun 11 '15 at 08:51I've read that this plugin is part of MMQGIS plugin, which has a "distance to hub" function. I used that tool but unfortunately, it locates the centroid of a nearest object, rather than the actual nearest edge of a line... so for this reason I don't think the tool will work (though I'll still give it a try, I want to learn how to use python commands for my own experience!).
I've now used an alternative way to solve my problem - I'll post it as an answer. But thank you anyway fro your help :)
– Cai Ladd Jun 11 '15 at 09:27