Geographic Information Systems Asked by Santiago Tissoni on February 19, 2021
I got a OSMNX graph, and put edges and nodes in two separated GeoDataFrames.
Now I want to delete the nodes that dont intersect with the edges, or nodes that are not very, very close to the edges.
I have the following:
nodes = gpd.read_file(NODES, encoding = 'utf-8')
streets = gpd.read_file(STREETS, encoding = 'utf-8')
EPS = 1e-12
streets_unary_union = streets['geometry'].unary_union
nodes['intersects'] = nodes['geometry'].apply(lambda x: x.intersects(streets_unary_union) or streets_unary_union.distance(x) < EPS)
This simply takes all the streets, and make an unique geometry, then compare every node with this unique geometry. So if a node and the geometry are intersecting or they are very close, I will keep whith that node.
The problem with this is takes TOO long (2 hours approximately) to eliminate maybe 100 or 200 nodes from a set of 15k nodes and 23k edges aprox. I am pretty sure that there is a solution to make this faster.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP