我遇到了一个奇怪的问题:在Jupyter笔记本电脑中使用GeoPandas时,.crs数据在我的第一个笔记本电脑上运行正常,然后在我的第二个笔记本电脑上丢失了。
只需查看图书馆随附的一张世界地图,然后运行此单元格...
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.crs
...在我的第一个笔记本中返回...
{'init': 'epsg:4326'}
...,当我在第二本笔记本中得到...
{}
最重要的(或由于这个原因),匹配的crs在第一个笔记本中有效,而在第二个笔记本中无效。在笔记本1中...
mal0 = gpd.read_file('./bird-species/E00039600_mallard.gdb', layer=0)
mal0 = mal0.to_crs(world.crs)
mal0.crs
返回...
{'init': 'epsg:4326'}
...符合预期,但是在笔记本2中会引发错误:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-10-fd67623093a6> in <module>
1 mal0 = gpd.read_file('./bird-species/E00039600_mallard.gdb', layer=0)
----> 2 mal0 = mal0.to_crs(world.crs)
3 mal0.crs
~/anaconda3/lib/python3.6/site-packages/geopandas/geodataframe.py in to_crs(self, crs, epsg, inplace)
441 else:
442 df = self.copy()
--> 443 geom = df.geometry.to_crs(crs=crs, epsg=epsg)
444 df.geometry = geom
445 df.crs = geom.crs
~/anaconda3/lib/python3.6/site-packages/geopandas/geoseries.py in to_crs(self, crs, epsg)
303 raise TypeError('Must set either crs or epsg for output.')
304 proj_in = pyproj.Proj(self.crs, preserve_units=True)
--> 305 proj_out = pyproj.Proj(crs, preserve_units=True)
306 project = partial(pyproj.transform, proj_in, proj_out)
307 result = self.apply(lambda geom: transform(project, geom))
~/anaconda3/lib/python3.6/site-packages/pyproj/__init__.py in __new__(self, projparams, preserve_units, **kwargs)
360 # on case-insensitive filesystems).
361 projstring = projstring.replace('EPSG','epsg')
--> 362 return _proj.Proj.__new__(self, projstring)
363
364 def __call__(self, *args, **kw):
_proj.pyx in _proj.Proj.__cinit__()
RuntimeError: b'no arguments in initialization list'
有人知道这是怎么回事吗?
答案 0 :(得分:0)
我有完全一样的问题。我可以不用jupyter用geopandas 0.6.1。来重现它。
这是无用的错误消息的情况。实际的错误是Geopandas不支持您的crs。