2

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?

8
  • 1
    How did you install geopandas and its dependencies? – joris Jun 16 '19 at 17:34
  • I used conda install -c conda-forge geopandas – zampnrs Jun 16 '19 at 20:40
  • Error message means that some support files which are needed by the proj library are not found. Did you set GDAL_DATA as adviced? – user30184 Jun 16 '19 at 20:58
  • Sorry, but how do I do this? – zampnrs Jun 16 '19 at 22:31
  • Are you running this code from an activated conda environment or are you using an IDE and just pointing to the python interpreter in your conda environment? – user2856 Jun 17 '19 at 6:12
1

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

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.