SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.42k stars 363 forks source link

Unable to run example #1791

Open danjampro opened 3 years ago

danjampro commented 3 years ago

Description

Hello, I am unable to run the basic example found here after installing following the given instructions. Installing from source using pip does not help.

I am using Mac OSX 11.3.1.

Traceback:

Python 3.8.5 (default, Sep  4 2020, 02:22:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cartopy.crs as ccrs
   ...: import matplotlib.pyplot as plt
   ...:
   ...: ax = plt.axes(projection=ccrs.Mollweide())
   ...: ax.stock_img()
   ...: plt.show()
Shell is not a LinearRing
Shell is not a LinearRing
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-a662b02540c6> in <module>
      3
      4 ax = plt.axes(projection=ccrs.Mollweide())
----> 5 ax.stock_img()
      6 plt.show()

~/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in stock_img(self, name)
   1017                                  '50-natural-earth-1-downsampled.png')
   1018
-> 1019             return self.imshow(imread(fname), origin='upper',
   1020                                transform=source_proj,
   1021                                extent=[-180, 180, -90, 90])

~/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in wrapper(self, *args, **kwargs)
    319
    320         kwargs['transform'] = transform
--> 321         return func(self, *args, **kwargs)
    322     return wrapper
    323

~/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in imshow(self, img, *args, **kwargs)
   1321                                  'handle a %s in imshow.' % type(transform))
   1322
-> 1323             target_extent = self.get_extent(self.projection)
   1324             regrid_shape = kwargs.pop('regrid_shape', 750)
   1325             regrid_shape = self._regrid_shape_aspect(regrid_shape,

~/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in get_extent(self, crs)
    766
    767         """
--> 768         p = self._get_extent_geom(crs)
    769         r = p.bounds
    770         x1, y1, x2, y2 = r

~/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py in _get_extent_geom(self, crs)
    814                                                 self.projection)
    815         else:
--> 816             geom_in_crs = boundary_poly.intersection(domain_in_src_proj)
    817
    818         return geom_in_crs

~/opt/anaconda3/lib/python3.8/site-packages/shapely/geometry/base.py in intersection(self, other)
    674     def intersection(self, other):
    675         """Returns the intersection of the geometries"""
--> 676         return geom_factory(self.impl['intersection'](self, other))
    677
    678     def symmetric_difference(self, other):

~/opt/anaconda3/lib/python3.8/site-packages/shapely/topology.py in __call__(self, this, other, *args)
     62
     63     def __call__(self, this, other, *args):
---> 64         self._validate(this)
     65         self._validate(other, stop_prepared=True)
     66         product = self.fn(this._geom, other._geom, *args)

~/opt/anaconda3/lib/python3.8/site-packages/shapely/topology.py in _validate(self, ob, stop_prepared)
     16     def _validate(self, ob, stop_prepared=False):
     17         if ob is None or ob._geom is None:
---> 18             raise ValueError("Null geometry supports no operations")
     19         if stop_prepared and hasattr(ob, 'prepared'):
     20             raise ValueError("Prepared geometries cannot be operated on")

ValueError: Null geometry supports no operations
dopplershift commented 3 years ago

What version of Shapely do you have installed? How did you install that?

khider commented 3 years ago

I'm getting a slightly different error using the same example. Everything goes well until the plt.show() command

`Shell is not a LinearRing Shell is not a LinearRing /Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/mpl/feature_artist.py:152: UserWarning: Unable to determine extent. Defaulting to global. warnings.warn('Unable to determine extent. Defaulting to global.') Shell is not a LinearRing Traceback (most recent call last):

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/IPython/core/formatters.py", line 341, in call return printer(obj)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/IPython/core/pylabtools.py", line 248, in png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/IPython/core/pylabtools.py", line 132, in print_figure fig.canvas.print_figure(bytes_io, **kw)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2193, in print_figure self.figure.draw(renderer)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw mimage._draw_list_compositing_images(

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py", line 517, in draw return matplotlib.axes.Axes.draw(self, renderer=renderer, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper return func(*inner_args, **inner_kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2748, in draw mimage._draw_list_compositing_images(renderer, self, artists)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/mpl/feature_artist.py", line 216, in draw c.draw(renderer)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/collections.py", line 931, in draw Collection.draw(self, renderer)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/collections.py", line 348, in draw transform, transOffset, offsets, paths = self._prepare_points()

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/collections.py", line 325, in _prepare_points paths = [transform.transform_path_non_affine(path)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/collections.py", line 325, in paths = [transform.transform_path_non_affine(path)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/matplotlib/transforms.py", line 2361, in transform_path_non_affine return self._a.transform_path_non_affine(path)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py", line 193, in transform_path_non_affine proj_geom = self.target_projection.project_geometry(

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/crs.py", line 201, in project_geometry return getattr(self, method_name)(geometry, src_crs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/crs.py", line 306, in _project_multiline r = self._project_line_string(geom, src_crs)

File "/Users/deborahkhider/opt/anaconda3/envs/pyleoclim/lib/python3.8/site-packages/cartopy/crs.py", line 207, in _project_line_string return cartopy.trace.project_linear(geometry, src_crs, self)

File "lib/cartopy/trace.pyx", line 625, in cartopy.trace.project_linear

File "lib/cartopy/trace.pyx", line 72, in cartopy.trace.geos_from_shapely

TypeError: an integer is required

<Figure size 432x288 with 1 Axes>`

I'm using Shapely 1.7.1