Reputation: 47
I have a shapefile of historical county boundaries with a valid .prj file. I can open it in ArcGIS and find that the projection is USA Contiguous Albers Equal Area Conic. I can also plot the shapefile after I have read it into geopandas and the projection looks correct.
However, I can't print the name of the coordinate system in my Python IDE.
If you read in the built in data from geopandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
and then run
print(world.crs)
you get
{'init': 'epsg:4326'}
But if I run
counties1910 = gpd.read_file('counties1910.shp')
print(counties1910.crs)
all I get is
{}
Additionally, I have found that while I can manually run
counties1910.crs = {'init' :'epsg:102003'}
without an error, I do get an error if I try to reproject 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)
What am I missing?
Thanks!
Upvotes: 0
Views: 1604
Reputation: 7804
USA Contiguous Albers Equal Area Conic is ESRI:102003. Because you are using old version of GeoPandas and pyproj, it does not automatically pick it.
Because you are passing it as EPSG:102003, not ESRI, it raises that error.
This should work as intended in GeoPandas 0.7.0 and 0.8.0, which uses pyproj.CRS
class to store projection information. You will ideally fix it by updating to the latest release (0.8.0).
Alternatively, pass CRS as ESRI (but recommended is an update, if possible).
counties1910.crs = {'esri:102003'}
Upvotes: 2