Skip to content
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

Stuck while loading 10m oceans #403

Closed
BertrandBordage opened this issue Apr 7, 2014 · 8 comments
Closed

Stuck while loading 10m oceans #403

BertrandBordage opened this issue Apr 7, 2014 · 8 comments

Comments

@BertrandBordage
Copy link

When you try to draw high-resolution oceans, cartopy gets stuck in an infinite loop. I redownloaded the .shp file in case it was broken, but nothing changes.

Minimal example:

from matplotlib import pyplot
from cartopy.crs import PlateCarree
from cartopy.feature import NaturalEarthFeature, COLORS


ax = pyplot.axes(projection=PlateCarree())
ocean = NaturalEarthFeature(category='physical', name='ocean',
                            scale='10m', facecolor=COLORS['water'])
ax.add_feature(ocean)
pyplot.show()
@pelson
Copy link
Member

pelson commented Apr 8, 2014

What version of cartopy are you on? I know we did some work on this a while back and thought it may have been fixed.

@pelson
Copy link
Member

pelson commented Apr 8, 2014

P.S. Confirmed on master at 0a0b548.

@BertrandBordage
Copy link
Author

Experienced on both master and 0.10.

@BertrandBordage
Copy link
Author

In fact, it's not really stuck, it's just extremely slow.
It works, but after 8 minutes. If you plot the same ocean feature several times, it's only the first time that takes so much time.

@pelson
Copy link
Member

pelson commented Apr 10, 2014

In fact, it's not really stuck, it's just extremely slow.

Ah, that is useful to know, thanks @BertrandBordage. I suspect there is a thresholding issue somewhere down the line and the linestring is being interpolated to a crazy resolution. Hopefully I will get a chance to look at this next week some time (with a prevailing wind).

@BertrandBordage
Copy link
Author

Excellent! Thanks :)

@pelson
Copy link
Member

pelson commented Apr 25, 2014

I've done some digging this afternoon as to the cause of the painful performance. I ended up giving up on the python shapefile library - it was just too slow for global use. I suspect that we are going to need to make use of Fiona if it is available, and fall back to pyshp if it is not.

However, that was only half of the problem. I was expecting the geometry transform to be particularly slow, but it turned out to be the conversion from Path -> GEOS geometry which is really slow due to a high number of containment tests (https://github.com/SciTools/cartopy/blob/master/lib/cartopy/mpl/patch.py#L203). I've been playing with wrapping a library (clipper) which will allow us to accurately convert from the potentially non-simple Path geometry to a simple GEOS like geometry efficiently - this might be the best solution to the performance bottleneck.

Hopefully I can put some more time on this over the next week or so.

@QuLogic
Copy link
Member

QuLogic commented Oct 13, 2018

This appears fixed by #1000, once it's released, and provided you have fiona installed.

@QuLogic QuLogic closed this as completed Oct 13, 2018
@QuLogic QuLogic added this to the 0.17 milestone Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants