When I work with different CRS in GeoPandas, pyproj module always fires many FutureWarnings.

FutureWarning: '+init=<authority>:<code>' syntax is deprecated.
'<authority>:<code>' is the preferred initialization method.

I see them up to 5 in a row.

Here's a code that causes it:

In [1]: crs = 'epsg:3857'
In [2]: import geopandas as gpd
In [3]: df = gpd.read_file('rodovias.gpkg')

In [4]: df.crs
Out[4]: {'init': 'epsg:4326'}

In [5]: df.to_crs(crs)
/home/culebron/.local/lib/python3.7/site-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))
                     name                                           geometry
0                Arco Sul  MULTILINESTRING ((-5487151.115 -2940693.219, -...
1                   Leste  MULTILINESTRING ((-5482946.592 -2929361.487, -...

As you can see, I have no syntax like '+init=...' in my code.

Is there a workaround to silence the warnings, or ideally to fix their cause?

(edit: and please, don't vote close. I did Google before asking this, and found absolutely nothing on topic. Bothering the devs at geopandas github was a bad idea too.)

  • 1
    Or you can use df.to_crs(epsg=3857). – Kadir Şahbaz Jan 29 at 21:28

The +init=epsg:xxxx syntax (or in form of a {'init': 'epsg:xxx'}) is being deprecated in PROJ / pyproj (see here. You are indeed not using it directly, but, the previous releases of GeoPandas (<= 0.6) were still generating this format under the hood (e.g. when reading files, as you can see from the output of df.crs). That is the reason you see this warning.

The latest release of GeoPandas (>= 0.7) has fixed this, and with that version you shouldn't see the warning. With older versions, you can ignore the warning.

See the migration guide for more: https://geopandas.readthedocs.io/en/latest/projections.html#upgrading-to-geopandas-0-7-with-pyproj-2-2-and-proj-6

| improve this answer | |
  • oh, that's why I did not find it the issues section :) thanks! – culebrón Jan 29 at 21:54
  • 1
    I'm using geopandas v0.7.0 and I'm seeing this warning – Aaron Bramson Apr 17 at 8:03
  • 1
    @AaronBramson if you are not specifying the CRS yourself using the +init=epsg:xxxx syntax, and still get the warning, then please open an issue at github.com/geopandas/geopandas – joris Apr 17 at 11:32
  • If I follow the conversion guide, I get the error Cannot transform naive geometries. Please set a crs on the object first. when trying to set the crs...Ah ha: the correct syntax in THAT case is thisData.crs = 'epsg:4326' – Aaron Bramson Apr 20 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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