rspatial / terra

R package for spatial data handling https://rspatial.github.io/terra/reference/terra-package.html
GNU General Public License v3.0
543 stars 90 forks source link

GDAL Error 1: PROJ: proj_identify: Cannot find proj.db #1555

Closed jzadra closed 4 months ago

jzadra commented 4 months ago

I recently updated R from 4.3 to 4.4. I have since been encountering the warning/error:

> tigris::states(cb = T) Warning message: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL Error 1: PROJ: proj_identify: Cannot find proj.db

It does produce the desired output however, as far as I can tell.

I also get an error when I follow up the result with tigris::shift_geometry(geoid_column = "geoid"):

Error: crs not found: is it missing?
In addition: Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: PROJ: proj_identify: Cannot find proj.db
2: In CPL_crs_from_input(x) :
  GDAL Error 1: PROJ: proj_get_authorities_from_database: Cannot find proj.db

System info: terra: 1.7.78 (which appears to be newer than the version mentioned in similar issues that was supposed to fix this) sf: 1.0-16

terra::gdal(lib="all") gdal proj geos "3.5.3" "9.1.0" "3.11.0" macOS 14.5 R: 4.4.1

I have checked and do not have rgdal or rgeos installed. I used homebrew to install gdal, proj, and have verified and reinstalled them to no effect.

jzadra commented 4 months ago

I just tested by rolling back to R 4.2, and I do not get these errors. For that install:

terra 1.6.53 gdal: 3.4.2 proj 8.2.1 geos 3.10.2

kadyb commented 4 months ago

Did you install the binary version from CRAN without virtual environment? Maybe this thread will be helpful in some way: https://github.com/r-spatial/sf/issues/2353

rhijmans commented 4 months ago

It seems to me that tigris::shift_geometry uses "sf", not "terra", so you may be knocking on the wrong door here.

The problem is with your system and/or how sf or terra was installed on it and/or how GDAL was installed. (I think the issue you refer to had to do with installing the dev version of "terra" on windows).

jzadra commented 4 months ago

@kadyb It was helpful! I had been installing the prebuilt binaries from the Posit Package Manager. When I switched back to using cran.rstudio.com as my repo, the problem was solved!

Thank you!