[GIS] Can’t open shapefile with GeoPandas

geopandaspycharmpython

I downloaded a shapefile from the Brazilian Institute of Geography and Statistics (IBGE). I can open it on QGIS and work with it perfectly there, but I need to work with it using Python.

I'm trying to open it with GeoPandas using the code line bellow:

shp_pr = gpd.read_file("data/PR/PR.shp")

But I get the following errors:

proj_create: Cannot find proj.db
proj_create: no database context specified
ERROR 4: Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
proj_create: Cannot find proj.db
proj_create: no database context specified
Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
proj_create: Cannot find proj.db
proj_create: no database context specified

I've also tried with GDAL, using these code lines:

from osgeo import ogr

driver = ogr.GetDriverByName("ESRI Shapefile")
ds = driver.Open("data/PR/PR.shp", 0) #open your shapefile

But I get these errors:

proj_create: Cannot find proj.db
proj_create: no database context specified
ERROR 4: Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
proj_create: Cannot find proj.db
proj_create: no database context specified
Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.

I have all the ".cpg", ".dbf", ".prj", ".qpj", ".shp" and ".shx" files.

What is going wrong?

Best Answer

Just set the environment variable as PROJ_LIB with value as C:\Anaconda3\Library\share\proj. This address contains proj.db file.