GeoPandas .to_crs发生错误 [英] GeoPandas .to_crs running into errors

查看:88
本文介绍了GeoPandas .to_crs发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入形状文件并更改其crs,以获取具有正确投影的地图.

  map_sh = gpd.read_file(r'C:\ PATH \ VG250_Gemeindegrenzen_2018.shp')map_sh = map_sh.to_crs({'init':'epsg:25832'}) 

当我尝试执行它时,会出现以下错误:

  RuntimeError Traceback(最近一次通话)< ipython-input-7-8354f57e24ce>在< module>中---->1 map_sh = map_sh.to_crs({'init':'epsg:25832'})〜_AppData \ Local \ Continuum \ miniconda3 \ lib \ site-packages \ geopandas \ geodataframe.py in to_crs(self,crs,epsg,inplace)441其他:第442章->443 geom = df.geometry.to_crs(crs = crs,epsg = epsg)444 df.geometry = geom445 df.crs = geom.crs〜_AppData \ Local \ Continuum \ miniconda3 \ lib \ site-packages \ geopandas \ geoseries.py in to_crs(self,crs,epsg)302,除了TypeError:303raise TypeError('必须为输出设置crs或epsg.')->第304章第305章306专案=部分(pyproj.transform,proj_in,proj_out)〜\ AppData \ Local \ Continuum \ miniconda3 \ lib \ site-packages \ pyproj \ __ init__.py in __new __(自己,projparams,preserve_units,** kwargs)不区分大小写的文件系统上的360#).第361章->362 return _proj.Proj .__ new __(self,projstring)363364 def __call __(自己,* args,** kw):_proj.Proj .__ cinit __()中的_proj.pyxRuntimeError:b'初始化列表中没有参数' 

我已经有这个特定的错误,可以通过将pyproj更新到2.2.1版来解决,但是从昨天开始我又遇到了同样的错误.

可能会发生什么变化,从一天到另一天,代码都出现了错误?如何检查我的代码正在运行哪个版本的pyproj?我只知道命令:

 点冻结 

解决方案

请确保您指向的是有效的 epsg 文件.根据您安装软件包的方式,可以在以下位置找到

:
  • 〜\ AppData \ Local \ Continuum \ miniconda3 \ Library \ share \ gdal
  • 〜\ AppData \ Local \ Continuum \ miniconda3 \ Library \ share

这可以通过许多方式实现,但是我通常更喜欢手动指向要使用的gdal资源.为此,添加一个名为GDAL_DATA的环境变量,并将其指向上面列表中的第一个文件夹.之后,您可能必须重新启动python解释器或计算机,这取决于您使用的是什么.

如果您使用的是Windows,则设置GDAL以及所有依赖于GDAL的操作都会很痛苦,但是我发现使用 解决方案

Make sure that you are pointing to a valid epsg file. Depending on how you installed your packages this can be found in:

  • ~\AppData\Local\Continuum\miniconda3\Library\share\gdal
  • ~\AppData\Local\Continuum\miniconda3\Library\share

This can be achieved in many ways, but I generally prefer to manually point to the gdal resources I want to use. To do that, add an environment variable called GDAL_DATA, and point it to the first folder in the list above. After that, you may have to restart the python interpreter or you computer depending on what you are using.

If you are using Windows, Setting up GDAL and everything relying on that can be a painful experience, but I found installing it using those pre-compiled wheels being the easiest and most reliable solution. They are also frequently updated.

这篇关于GeoPandas .to_crs发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆