Pyproj – Using New Projection Initialization Method in GeoPandas

geopandaspyprojpython

Issue

Using GeoPandas:

this:

(...)
t_srs = 4326
gdf.set_geometry('geom', crs={'init': u'epsg:'+str(t_srs)}, inplace=True)

or this:

(...)
gpd.read_postgis(sql_string, conn, geom_col='geom', crs={'init': u'epsg:'+str(t_srs)})

raise a warning today:

/usr/local/lib/python3.6/dist-packages/pyproj/crs.py:77:     
FutureWarning: 
    '+init=<authority>:<code>' syntax is deprecated.     
    '<authority>:<code>'  is the preferred initialization method.
  return _prepare_from_string(" ".join(pjargs))

and if I remove the 'init' key of the crs dictionary, I got this error;

CRSError: Invalid CRS input: {'epsg:4326'}

And if, by chance, I try with {'epsg':'4326'} or {'epsg':4326} ; these errors are respectively raised:

CRSError: Invalid projection: {"epsg": "4326"}: (Internal Proj Error: proj_create: Missing "type" key)

and:

CRSError: Invalid projection: {"epsg": 4326}: (Internal Proj Error: proj_create: Missing "type" key)

Question

Is it already possible to write some GeoPandas code that corresponds to the new* pyproj projection initialization method using <authority>:<code> instead of +init=<authority>:<code> ?

Best Answer

'<authority>:<code>' in the error means that you need just to use crs='EPSG:4326' instead of crs={'epsg:4326'}.

Related Question