Hi, not sure if this is related to installation or dependencies problems, but I get a KeyError
exception whenever I try to use countries_50 or countries_110 with regionmask:
In [4]: regionmask.defined_regions.natural_earth.us_states_50
Out[4]:
51 'Natural Earth: US States 50m' Regions ()
AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY
In [5]: regionmask.defined_regions.natural_earth.countries_50
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2392 try:
-> 2393 return self._engine.get_loc(key)
2394 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5239)()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5085)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20405)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20359)()
KeyError: 'name'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-5-f6fe97505925> in <module>()
----> 1 regionmask.defined_regions.natural_earth.countries_50
/Users/stefano/anaconda/lib/python3.6/site-packages/regionmask/defined_regions/natural_earth.py in countries_50(self)
70 title='Natural Earth Countries: 50m')
71
---> 72 self._countries_50 = _obtain_ne(**opt)
73 return self._countries_50
74
/Users/stefano/anaconda/lib/python3.6/site-packages/regionmask/defined_regions/natural_earth.py in _obtain_ne(resolution, category, name, title, names, abbrevs, coords, query)
22 # GET NECESSARY DATA FOR Regions_cls
23 numbers = np.array(gp.index)
---> 24 names = gp[names]
25 abbrevs = gp[abbrevs]
26 coords = gp[coords]
/Users/stefano/anaconda/lib/python3.6/site-packages/geopandas/geodataframe.py in __getitem__(self, key)
396 GeoDataFrame.
397 """
--> 398 result = super(GeoDataFrame, self).__getitem__(key)
399 geo_col = self._geometry_column_name
400 if isinstance(key, string_types) and key == geo_col:
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
2060 return self._getitem_multilevel(key)
2061 else:
-> 2062 return self._getitem_column(key)
2063
2064 def _getitem_column(self, key):
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
2067 # get column
2068 if self.columns.is_unique:
-> 2069 return self._get_item_cache(key)
2070
2071 # duplicate columns & possible reduce dimensionality
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
1532 res = cache.get(item)
1533 if res is None:
-> 1534 values = self._data.get(item)
1535 res = self._box_item_values(item, values)
1536 cache[item] = res
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
3588
3589 if not isnull(item):
-> 3590 loc = self.items.get_loc(item)
3591 else:
3592 indexer = np.arange(len(self.items))[isnull(self.items)]
/Users/stefano/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2393 return self._engine.get_loc(key)
2394 except KeyError:
-> 2395 return self._engine.get_loc(self._maybe_cast_indexer(key))
2396
2397 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5239)()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5085)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20405)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20359)()
KeyError: 'name'
stefano ~ $ pip install regionmask
Collecting regionmask
Downloading regionmask-0.3.1-py3-none-any.whl
Requirement already satisfied: cartopy in ./anaconda/lib/python3.6/site-packages (from regionmask)
Requirement already satisfied: shapely in ./anaconda/lib/python3.6/site-packages (from regionmask)
Collecting geopandas (from regionmask)
Downloading geopandas-0.3.0-py2.py3-none-any.whl (888kB)
100% |################################| 890kB 656kB/s
Requirement already satisfied: matplotlib in ./anaconda/lib/python3.6/site-packages (from regionmask)
Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages (from regionmask)
Requirement already satisfied: six in ./anaconda/lib/python3.6/site-packages (from regionmask)
Requirement already satisfied: pyshp>=1.1.4 in ./anaconda/lib/python3.6/site-packages (from cartopy->regionmask)
Requirement already satisfied: setuptools>=0.7.2 in ./anaconda/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg (from cartopy->regionmask)
Requirement already satisfied: pandas in ./anaconda/lib/python3.6/site-packages (from geopandas->regionmask)
Requirement already satisfied: pyproj in ./anaconda/lib/python3.6/site-packages (from geopandas->regionmask)
Collecting descartes (from geopandas->regionmask)
Downloading descartes-1.1.0-py3-none-any.whl
Collecting fiona (from geopandas->regionmask)
Downloading Fiona-1.7.10.post1-cp36-cp36m-macosx_10_9_intel.macosx_10_9_x86_64.whl (24.7MB)
100% |################################| 24.7MB 35kB/s
Requirement already satisfied: python-dateutil>=2.0 in ./anaconda/lib/python3.6/site-packages (from matplotlib->regionmask)
Requirement already satisfied: pytz in ./anaconda/lib/python3.6/site-packages (from matplotlib->regionmask)
Requirement already satisfied: cycler>=0.10 in ./anaconda/lib/python3.6/site-packages (from matplotlib->regionmask)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./anaconda/lib/python3.6/site-packages (from matplotlib->regionmask)
Collecting munch (from fiona->geopandas->regionmask)
Downloading munch-2.2.0.tar.gz
Collecting click-plugins (from fiona->geopandas->regionmask)
Downloading click-plugins-1.0.3.tar.gz
Collecting cligj (from fiona->geopandas->regionmask)
Downloading cligj-0.4.0-py3-none-any.whl
Requirement already satisfied: click>=3.0 in ./anaconda/lib/python3.6/site-packages (from click-plugins->fiona->geopandas->regionmask)
Building wheels for collected packages: munch, click-plugins
Running setup.py bdist_wheel for munch ... done
Stored in directory: /Users/stefano/Library/Caches/pip/wheels/6b/a7/c4/fee97ae4038d2e41e1c862f5940237293b613d2dadd078c0b4
Running setup.py bdist_wheel for click-plugins ... done
Stored in directory: /Users/stefano/Library/Caches/pip/wheels/70/d7/3d/188128669f2aa42f6008217d9e2e6826d398dc3e361c0fcb75
Successfully built munch click-plugins
Installing collected packages: descartes, munch, click-plugins, cligj, fiona, geopandas, regionmask
Successfully installed click-plugins-1.0.3 cligj-0.4.0 descartes-1.1.0 fiona-1.7.10.post1 geopandas-0.3.0 munch-2.2.0 regionmask-0.3.1