Reputation: 453
I need to do some spatial operations in geopandas. I created the new conda environment and installed geopandas conda install --channel conda-forge geopandas
. When I run the following simple code:
import geopandas as gpd
from shapely.geometry import Point
gdf = gpd.GeoDataFrame([Point(1,1)])
gdf.set_geometry(0).set_crs(epsg=3857)
I get the following error message :
CRSError: Invalid projection: EPSG:3857: (Internal Proj Error: proj_create: no database context specified)
I tried to google the issue. There are several posts, yet I could not find the right solution. It seems that there is a problem with pyproj database. That's what I understood so far.
Any solutions?
Thanks in advance!
Upvotes: 0
Views: 491
Reputation: 18812
The error is in the step gdf.set_geometry(0)
. Try this instead:
import geopandas as gpd
from shapely.geometry import Point
gdf = gpd.GeoDataFrame([Point(1,1)])
# Dont do this
# gdf.set_geometry(0).set_crs(epsg=3857)
# But do it in 2 steps
gdf.set_geometry(0, inplace=True)
gdf.set_crs(epsg=3857, inplace=True)
gdf.plot()
Without inplace=True
in gdf.set_geometry()
, gdf
object is not ready to do .set_crs()
, thus, causes the error.
Upvotes: 0