Search code examples
cartopymetpy

metpy.plots issue with Cartopy Natural Earth


I just noticed that when I try to import metpy.plots on NCAR's Cheyenne supercomputer, it loads and works fine when using metpy 0.10.0 (with Cartopy 0.17.0), but I get an error with metpy 0.12.0 or 0.12.1 (with Cartopy 0.18.0b2). This is the error I get:

(NPL) jaredlee@cheyenne3:~> python3
Python 3.6.8 (default, Jun 27 2019, 20:02:05) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import metpy
>>> metpy.__version__
'0.12.1'
>>> import metpy.plots as mpplots
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/glade/work/jaredlee/python/my_npl_clone_20200417/lib/python3.6/site-packages/metpy/plots/__init__.py", line 27, in <module>
    from .cartopy_utils import USCOUNTIES, USSTATES
  File "/glade/work/jaredlee/python/my_npl_clone_20200417/lib/python3.6/site-packages/metpy/plots/cartopy_utils.py", line 43, in <module>
    USCOUNTIES = MetPyMapFeature('us_counties', '20m', facecolor='None', edgecolor='black')
  File "/glade/work/jaredlee/python/my_npl_clone_20200417/lib/python3.6/site-packages/metpy/plots/cartopy_utils.py", line 16, in __init__
    super().__init__('', name, scale, **kwargs)
  File "/glade/work/jaredlee/python/my_npl_clone_20200417/lib/python3.6/site-packages/cartopy/feature/__init__.py", line 264, in __init__
    self._validate_scale()
  File "/glade/work/jaredlee/python/my_npl_clone_20200417/lib/python3.6/site-packages/cartopy/feature/__init__.py", line 274, in _validate_scale
    'Valid scales are "110m", "50m", and "10m".'
ValueError: 20m is not a valid Natural Earth scale. Valid scales are "110m", "50m", and "10m".
>>> 

If I manually change cartopy_utils.py in my local copy of metpy so that the USCOUNTIES and USSTATES function calls to MetPyMapFeature use '10m' instead of '20m', then the error goes away. Is this '20m' a bug in cartopy_utils.py? Natural Earth's webpage advertises that it provides data at 1:10m, 1:50m, and 1:110m scales.


Solution

  • MetPy <=0.12.1 is incompatible with CartoPy 0.18. As pointed out by Daryl in his comment, this is an open issue that will hopefully be resolved soon.