I have recently started using Geopandas and am having a problem with the performance of intersects. The intersect tests whether land parcels have a road within (or across the boundary).
Parcel data (parcels) is a polygon geodataframe and roads (roads) are as a line geodataframe. I attempt to find out if the parcel interacts with a road with the follwoing code:
road = roads.unary_union
parcels['road_intersection'] = parcels.intersects(road)
Here I generate get a column 'road_intersection' with True/False values.
with 985 parcel polygons and 20854 road lines, this takes over a minute to generate a result.
I have previously tried with
parcels['road_intersection'] = parcels.intersects(roads)
but this did not seem to test all roads with all parcels.
Would anyone be able to provide any tips for correct use or optimisation?
No comments:
Post a Comment