terra icon indicating copy to clipboard operation
terra copied to clipboard

GDAL not linked when installing terra from binaries in renv environment

Open elisehellwig opened this issue 1 year ago • 4 comments

MacOS Ventura 13.5.2 (Apple M2 chip) terra - v. 1.7.46

When I run the following code (terra installed via binaries)

renv::init()

install.packages('terra')
install.packages('geodata')

library('terra')
library('geodata')

usa = gadm('USA', level=, path='data')

usa_ca = project(usa, "epsg:3310")

I get the output/error message

Error: [project] output crs is not valid In addition: Warning message: PROJ: proj_create_from_database: Cannot find proj.db (GDAL error 1)

However, when I install terra from source (code below), it runs with no issues.

renv::init()

install.packages("Rcpp")
install.packages("terra", type = "source", configure.args = "--with-proj-lib=$(brew --prefix)/lib/")
install.packages('geodata')

library('terra')
library('geodata')

usa = gadm('USA', level=1, path='data')

usa_ca = project(usa, "epsg:3310")

It seems like when I install terra from the binaries in the renv environment, terra is unable to find GDAL.

As a note, this is also an issue for raster, but I figured raster compatibility with renv is less of a priority.

elisehellwig avatar Sep 25 '23 17:09 elisehellwig

completely new install, desktop ubuntu 23.10. R at 4.3.1, just installed via apt. no local config etc. files.

install.packages("terra") dies for me at

checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.

not sure what gdal is or how to install it. doesn't seem to be an apt package or an R package.

regards,

/iaw

iwelch avatar Nov 15 '23 22:11 iwelch

Hi Ivo,

GDAL is a software package that many other programs use to support reading/writing geographic data as well as many geographic transformations. It should be installed automatically with terra, but for some reason that doesn't happen inside an renv virtual environment. You can install it separately (see terra README) but if you aren't installing from source that shouldn't be necessary.

-Elise

elisehellwig avatar Nov 15 '23 22:11 elisehellwig

hi elise --- mine was not in a virtual environment...though I am not even sure what this means.  it was in a pure and fresh ubuntu install and a command line invocation of R.

way to fix this was by hand

sudo apt-get install -y libgdal-dev

just trying to help, of course.

iwelch avatar Nov 15 '23 23:11 iwelch

Installing libgdal-dev worked for me as well (Ubuntu 23.10), but only after removing libmariadb-dev, which was causing some conflicts.

wleoncio avatar Feb 16 '24 15:02 wleoncio