I am curious to know on how to implement NNJoin into the python code. I have created a point shapefile using shapely. I have another shapefile which is a centerline and is used as a reference line. Now I want to find the shortest distance from each point to the centerline. The way which I have done so far is converted the centerline shapefile into points and used NNJoin to find the shortest distance and the nearest coordinates of the point on the centerline. I want to know as to how I can implement the NNJoin using python.
Is there a way to import NNJoin as a library and use it?
If not are there any alternatives to it which I can use?
Answer
NNjoin joins two vector layers based on nearest neighbour relationships and it use GEOS as Shapely.
In Python it is quicker to use a Spatial Index as Rtree (Nearest Neighbours). There are many examples of the use of this module with Shapely and Fiona on the Web and GIS SE.
A solution with Shapely (without a Spatial Index) is given in Nearest neighbor between point layer and line layer?
And a comparison of all the Python solutions is proposed in Benchmarking Nearest Neighbor Searches in Python
No comments:
Post a Comment