I'm trying to set the coordinate reference system for a GeoDataFrame
using the following code:
import geopandas
from shapely.geometry import shape
from shapely.geometry import Point
d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
gdf = geopandas.GeoDataFrame(d)
gdf = gdf.set_crs('epsg:3857')
However, when running gdf.set_crs('epsg:3857')
, I receive the following error:
File "C:\Users\username\AppData\Local\Programs\Python\Python39\my_env\lib\site-packages\pandas\core\generic.py", line 5487, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'GeoDataFrame' object has no attribute 'set_crs'
I looked inside geodataframe.py
and indeed there is no object called set_crs
. How do I get the set_crs
object in here? FYI I installed GeoPandas from https://www.lfd.uci.edu/~gohlke/pythonlibs/.
I tried copying the set_crs
object (found here: https://github.com/geopandas/geopandas/blob/528abfc6fe4a501ebffa7aa16cb05a5aa656c8dd/geopandas/geodataframe.py#L1116) into geodataframe.py
, but it did not solve the issue. Instead I received more errors.
set_crs
method was added in geopandas 0.8.0. There's two versions on lfd.uci.edu/~gohlke/pythonlibs, did you install the old 0.6.2 version instead of 0.10.2?gdf.set_crs('epsg:3857')
works without problems, I am on GeoPandas 0.10.2.