【发布时间】:2020-06-29 16:42:13
【问题描述】:
我有一个历史县界的 shapefile 和一个有效的 .prj 文件。我可以在ArcGIS中打开,发现投影是USA Contiguous Albers Equal Area Conic。我也可以在将 shapefile 读入 geopandas 后绘制它,并且投影看起来正确。
但是,我无法在 Python IDE 中打印坐标系的名称。
如果您从 geopandas 读取内置数据
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
然后运行
print(world.crs)
你得到
{'init': 'epsg:4326'}
但如果我跑了
counties1910 = gpd.read_file('counties1910.shp')
print(counties1910.crs)
我得到的只是
{}
另外,我发现虽然我可以手动运行
counties1910.crs = {'init' :'epsg:102003'}
没有错误,如果我尝试重新投影counties1910,我确实会收到错误:
counties1910 = counties1910.to_crs("EPSG:4326")
--------------------------------------------------------------------------
CRSError Traceback (most recent call last)
<ipython-input-148-4aa2873c2f22> in <module>
----> 1 counties1910 = counties1910.to_crs("EPSG:4326")
~\AppData\Local\Continuum\anaconda3\lib\site-packages\geopandas\geodataframe.py in to_crs(self, crs, epsg, inplace)
532 else:
533 df = self.copy()
--> 534 geom = df.geometry.to_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 # skip transformation if the input CRS and output CRS are the exact same
409 if _PYPROJ_VERSION >= LooseVersion("2.1.2") and pyproj.CRS.from_user_input(
--> 410 self.crs
411 ).is_exact_same(pyproj.CRS.from_user_input(crs)):
412 return self
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyproj\crs\crs.py in from_user_input(value, **kwargs)
438 if isinstance(value, CRS):
439 return value
--> 440 return CRS(value, **kwargs)
441
442 def get_geod(self) -> Optional[Geod]:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyproj\crs\crs.py in __init__(self, projparams, **kwargs)
294 projstring = _prepare_from_string(" ".join((projstring, projkwargs)))
295
--> 296 super().__init__(projstring)
297
298 @staticmethod
pyproj/_crs.pyx in pyproj._crs._CRS.__init__()
CRSError: Invalid projection: +init=epsg:102003 +type=crs: (Internal Proj Error: proj_create: crs not found)
我错过了什么?
谢谢!
【问题讨论】:
标签: projection shapefile geopandas