Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Projection 使用read_file()将shapefile导入geopandas;can';不打印crs或重新投影_Projection_Shapefile_Geopandas - Fatal编程技术网

Projection 使用read_file()将shapefile导入geopandas;can';不打印crs或重新投影

Projection 使用read_file()将shapefile导入geopandas;can';不打印crs或重新投影,projection,shapefile,geopandas,Projection,Shapefile,Geopandas,我有一个带有有效.prj文件的历史县边界形状文件。我可以在ArcGIS中打开它,发现投影是美国相邻的Albers等面积圆锥曲线。我还可以在将shapefile读入geopandas后绘制它,并且投影看起来是正确的 但是,我无法在Python IDE中打印坐标系的名称 如果从geopandas读取内置数据 world=gpd.read\u文件(gpd.dataset.get\u路径('naturalearth\u lowres')) 然后跑 print(world.crs) 你得到 {'init'

我有一个带有有效.prj文件的历史县边界形状文件。我可以在ArcGIS中打开它,发现投影是美国相邻的Albers等面积圆锥曲线。我还可以在将shapefile读入geopandas后绘制它,并且投影看起来是正确的

但是,我无法在Python IDE中打印坐标系的名称

如果从geopandas读取内置数据

world=gpd.read\u文件(gpd.dataset.get\u路径('naturalearth\u lowres'))

然后跑

print(world.crs)

你得到

{'init':'epsg:4326'}

但如果我跑

counties1910=gpd.read\u文件('counties1910.shp')

print(countries1910.crs)

我得到的只是

{}

此外,我发现虽然我可以手动运行

counties1910.crs={'init':'epsg:102003'}

如果没有错误,如果我尝试重新投影Countries 1910,我确实会出错:

counties1910=counties1910.to_crs(“EPSG:4326”)

--------------------------------------------------------------------------
CRSRERROR回溯(最近一次呼叫最后一次)
在里面
---->1 Countries1910=Countries1910.to_crs(“EPSG:4326”)
~\AppData\Local\Continuum\anaconda3\lib\site packages\geopandas\geodataframe.py in to_crs(self、crs、epsg、inplace)
532其他:
533 df=self.copy()
-->534 geom=df.几何体至crs(crs=crs,epsg=epsg)
535 df.geometry=geom
536 df.crs=geom.crs
~\AppData\Local\Continuum\anaconda3\lib\site packages\geopandas\geoseries.py-in-to_-crs(self、crs、epsg)
408#如果输入CR和输出CR完全相同,则跳过转换
409如果PYPROJ版本>=LooseVersion(“2.1.2”)和PYPROJ.CRS.from用户输入(
-->410自我控制系统
411).是否完全相同(来自用户输入(CRS)的pyproj.CRS):
412回归自我
~\AppData\Local\Continuum\anaconda3\lib\site packages\pyproj\crs\crs.py从用户输入(值,**kwargs)
438如果存在(值,CRS):
439返回值
-->440返回CRS(值,**kwargs)
441
442 def get_geod(自)->可选[geod]:
~\AppData\Local\Continuum\anaconda3\lib\site packages\pyproj\crs\crs.py in\uuuuu init\uuuu(self,projparams,**kwargs)
294 projstring=_prepare_from_string(“.”).join((projstring,projkwargs)))
295
-->296 super()
297
298@staticmethod
pyproj/_crs.pyx在pyproj._crs._crs.uuu init_uuuuuuuu()中
CRSError:无效投影:+init=epsg:102003+type=crs:(内部项目错误:项目创建:未找到crs)
我错过了什么


谢谢

美国邻接阿尔伯斯等面积圆锥曲线为ESRI:102003。因为您使用的是旧版本的GeoPandas和pyproj,所以它不会自动拾取它

因为您将其作为EPSG:102003而不是ESRI传递,所以会引发该错误

这应该按照GeoPandas 0.7.0和0.8.0中的预期工作,它使用
pyproj.CRS
类来存储投影信息。理想情况下,您可以通过更新到最新版本(0.8.0)来修复它

或者,将CRS作为ESRI传递(但如果可能,建议进行更新)

counties1910.crs={'esri:102003'}

美国连续阿尔伯斯等面积圆锥曲线为ESRI:102003。因为您使用的是旧版本的GeoPandas和pyproj,所以它不会自动拾取它

因为您将其作为EPSG:102003而不是ESRI传递,所以会引发该错误

这应该按照GeoPandas 0.7.0和0.8.0中的预期工作,它使用
pyproj.CRS
类来存储投影信息。理想情况下,您可以通过更新到最新版本(0.8.0)来修复它

或者,将CRS作为ESRI传递(但如果可能,建议进行更新)

counties1910.crs={'esri:102003'}