When I try and follow the answer to the question on European Map using R about plotting a map some objects on top of it based on their longitude/latitude coordinates, I run into problems installing sf
, with some dependencies of it apparently deprecated.
What could be a solution that works with a current version of R (2024)?
Specifically, on installing library sf
using the standard install.packages()
function I run into the problem of a missing dependency,
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
I am installing on a Debian box from source as the R installation needs to be managed by non-root users.
One gets the same error message when trying to install rgdal
directly. Notably, rgdal
is deprecated for current versions or R. The CRAN page for rgdal
actually suggests using sf
or terra
instead.
Installing a binary gdal library as suggested in the question about the Error: gdal-config not found while installing R dependent packages whereas gdal is installed also did not help, and neither did installing other gdal packages:
apt-get install libudunits2-dev libgdal-dev gdal-bin gdal-data gdal-plugins
Has anyone managed to get sf
installed on a current version of R or can someone suggest an efficient way of plotting a map of Europe and some objects on top of it based on their longitude/latitude coordinates?
sf has "system requirements" GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0), sqlite3.
If you are installing from source on linux or mac, you need to install these first. You can see this on the CRAN webpage. None of this is directly related to the retired "rgdal" package.
Detailed installation instructions for "sf" are available here (and the same instructions also apply for package "terra"). The exact instructions depend on your OS. It looks like you are using a linux but you do not specify which flavor; making it impossible to know what would apply to your case, exactly.
Using r2U can be a more convenient way to achieve your goal.
If you are on Windows there is no need for any of this. Even for the development version as you can use the R-Universe binary installer like this:
install.packages('terra', repos='https://rspatial.r-universe.dev')