2

My question is about setting the GDAL_DATA environment variable to the right directory. I have read some posts where they had the same issue as me and the advice was to set the GDAL_DATA environment, but I'm at a loss of how to do that.

I am using rasterio (& rioxarray) to reproject a raster to another CRS. This worked until I tried to install some other stuff on linux and now I get the following error when I try to run it:

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.

The script still runs, but when it gets to the reprojection:

worldpop = worldpop.rio.reproject(dst_crs=region_gdf.crs, resolution=500, resampling=Resampling.bilinear)

I get the following error:

Traceback (most recent call last): File "rasterio/_base.pyx", line 1455, in rasterio._base._osr_from_crs File "rasterio/_err.pyx", line 192, in rasterio._err.exc_wrap_int rasterio._err.CPLE_AppDefinedError: PROJ: proj_create_from_database: Cannot find proj.db

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/jochem/Uppermoor/coronalocatie-datapipeline/uk/create_grid.py", line 47, in worldpop = worldpop.rio.reproject(dst_crs=region_gdf.crs, resolution=500, resampling=Resampling.bilinear) File "/home/jochem/.local/share/virtualenvs/coronalocatie-datapipeline-8r7cFbTs/lib/python3.9/site-packages/rioxarray/raster_array.py", line 371, in reproject rasterio.warp.reproject( File "/home/jochem/.local/share/virtualenvs/coronalocatie-datapipeline-8r7cFbTs/lib/python3.9/site-packages/rasterio/env.py", line 387, in wrapper return f(*args, **kwds) File "/home/jochem/.local/share/virtualenvs/coronalocatie-datapipeline-8r7cFbTs/lib/python3.9/site-packages/rasterio/env.py", line 610, in wrapper return f(*args, **kwds) File "/home/jochem/.local/share/virtualenvs/coronalocatie-datapipeline-8r7cFbTs/lib/python3.9/site-packages/rasterio/warp.py", line 363, in reproject _reproject( File "rasterio/_warp.pyx", line 399, in rasterio._warp._reproject File "rasterio/_warp.pyx", line 373, in rasterio._warp._reproject File "rasterio/_io.pyx", line 1765, in rasterio._io.InMemoryRaster.init File "rasterio/_base.pyx", line 1461, in rasterio._base._osr_from_crs rasterio.errors.CRSError: PROJ: proj_create_from_database: Cannot find proj.db

Some background information: I run this in a pip environment where rasterio is installed. The packages are installed in .local/share/virtualenvs/.../lib/python3.9/site-packages. I can find rasterio here, but the folder: rasterio/gdal_data does not contain a gcs.csv file.

Also, do I need to install GDAL seperately to make this work or is installing rasterio enough, because I struggle with getting GDAL installed as well.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

0 Answers0