-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A ~30 time faster implementation using shaplely 2.0 and Geopandas ? #42
Comments
Thanks for the brilliant solution, but the function should be modified to fit the latest version of GeoPandas:
Have a nice day! |
Hi @fitodic !
I think I found a (much) faster way to perform those calculations. Or at least, it is with the case with the data I tested with.
This is the python script I used to compare them:
In my testing, the proposed version takes 8.580s and the current version of Centerline takes 278.823s. Both versions give fairly similar results in therm of centerline network (see figure). I suppose the difference comes mainly from the segmenting algorithm, but I haven't explored this much. Note that the polygone.segmentize() is only available since version 2.0.0 of the shapely library.
I suppose the main speed-up comes from the way the inside vertices are calculated, as using the spatial join from geopandas is really fast.
I know this way of measuring calculation speed is not perfect and multiple times should at least be averaged out and with different initial polygons. But given the speed difference in my testing, I thought the difference was clear enough to not bother with more extensive testing for now.
To stay constant with the current behavior of the library, I transformed the geoDataFrame back to a shapely multiline. But I figured that is you implement those changes, the Centerline could stay a geoDataFrame as those are less difficult to work with (That's my opinion obviously).
Have a nice day
The text was updated successfully, but these errors were encountered: