Using GeoPandas:


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:

    '+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)


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


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> ?

2 Answers 2


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

  • 3
    Passing just EPSG number is also possible crs=4326. In the example above it would be the easiest way. Apr 2, 2020 at 9:35

As too often, I continue cobbling around with my code after having posted my question, and I figure it out:


Do not pass a dictionary but a string as a CRS!


I.e, in concrete terms, change the two previous pieces of code that thrown the FutureWarning into


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

or this:

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

Notice the parentheses instead of the curly braces, which mean now that crs is a string and no more a dictionary.

Here is, as an example, the help of the geopandas.read_postgis() method where it is discreetly suggested:

Help on function read_postgis in module geopandas.io.sql:

read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, coerce_float=True, parse_dates=None, params=None)
    Returns a GeoDataFrame corresponding to the result of the query
    string, which must contain a geometry column in WKB representation.

    sql : string
        SQL query to execute in selecting entries from database, or name
        of the table to read from the database.
    con : DB connection object or SQLAlchemy engine
        Active connection to the database to query.
    geom_col : string, default 'geom'
        column name to convert to shapely geometries
    crs : dict or str, optional
        CRS to use for the returned GeoDataFrame; if not set, tries to
        determine CRS from the SRID associated with the first geometry in
        the database, and assigns that to all geometries.

    See the documentation for pandas.read_sql for further explanation
    of the following parameters:
    index_col, coerce_float, parse_dates, params


sql = "SELECT geom, kind FROM polygons"
sql = "SELECT ST_AsBinary(geom) AS geom, kind FROM polygons"
df = geopandas.read_postgis(sql, con)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.