-
Notifications
You must be signed in to change notification settings - Fork 371
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
compatibility with shapely v2? #2076
Comments
Thanks for testing that! Looks like lgeos has been removed upstream: shapely/shapely#1163 Maybe it is time to look more at removing GEOS from our dependencies and fully relying on shapely. I think @QuLogic had a branch working on removing GEOS, but maybe it was too slow before? Perhaps shapely2.0 provides the speedups needed for the switch. |
I do have a branch for it, and I just rebased it, but haven't looked at the current speed, or whether 2.0 will help with that. There were definitely some optimizations available in pygeos (which I didn't apply yet) that I think was intended to become shapely 2.0, so they might be some improvements available. |
@QuLogic, I just looked through your branches, but didn't see anything pushed recently. Which branch was it? |
We should definitely make sure we pin 0.21 to Shapely < 2. |
I quickly looked into how cartopy is using Regarding compatibility with Shapely 2.0, I think there are two aspects: 1) just run with Shapely 2.0, and 2) make use of new features in Shapely 2.0 so cartopy can stop linking to GEOS itself (and just rely on Shapely to do that), i.e. to solve #805 (and what @QuLogic's branch is attempting). To get cartopy compatible with Shapely 2.0, a lot of the necessary changes were already done before (#1914, all things we could warn about in advance), and #2080 removes the last bit of API usage that was removed or changed in Shapely 2.0 (except for the usage of |
I opened a fix on the Shapely side (shapely/shapely#1535), although I am also wondering to what extent this is important for cartopy? (I didn't check the exact use case here)
@QuLogic this is this branch: https://github.com/QuLogic/cartopy/tree/shapely? (based on your comment from #805 (comment)) It might be easier to further discuss this when opening a draft PR? |
With geomtries being hashable in 2.0 the weakrefs could potentially be removed from Cartopy because it looks like we are using them in place of the old non-hashable geometries according to this comment: cartopy/lib/cartopy/mpl/feature_artist.py Lines 166 to 181 in 1198715
|
Slowdown: I get ~2x slowdown from @QuLogic's branch removing GEOS, which I think agrees with what he found before. (Rebased branch: https://github.com/greglucas/cartopy/tree/qulogic-delete-proj-geos) Some profiling tests (project_linear from the benchmarks) show some rough areas where we could improve. With GEOSWithout GEOSSome interesting observations from above:
|
With pyproj 3.2+, you could try the |
But that is not something for a 0.21.1 release, I assume? |
It might be easier to comment inline on a draft PR, but one idea to make this more efficient is to do |
Draft PR for discussion purposes: #2083 Good idea @snowman2, unfortunately it didn't help much. It looks like quite a bit of time is spent in |
So shapely 2.0.0 is out since dec 12 2022, and as far as i understand the fixes for this are still pending review. So I thought I could make a small PR to pin shapely to <2.0.0 in the meanwhile. Would that be ok? |
@mraspaud, Cartopy should be compatible with shapely 2.0.0 now are you still seeing issues? Please open a new issue with details if so. |
I am using Cartopy installed by the MacPorts system and it has installed Cartopy 0.21.0_0 with shapely 2.0.1_1. This combination is having the issue mentioned above
Is this combination supposed to be fixed? |
That line was fixed in 0.21.1, #2110. |
Description
The pre-release version of shapely v2 is out & that seems to break cartopy.
Code to reproduce
Install shapely v2 & cartopy and try to import cartopy:
mamba create -n cartopy_shapely_v2 -c conda-forge/label/shapely_dev shapely cartopy mamba activate cartopy_shapely_v2 python -c "import cartopy"
Traceback
Full environment definition
Operating system
linux
Cartopy version
cartopy 0.20.3
conda list
pip list
The text was updated successfully, but these errors were encountered: