I’m trying to install package "raster" in R for spatial analysis and some of the packages, those are not seem bo be installed with "raster – terra, raster, vis, rgdal.
I’ve tried so far:
install.packages("pbkrtes"),
install.packages("terra", dependencies = TRUE), etc
But it does not go…
Here is the pic of the last attempt.
I have ubuntu 22.04 and R 4.3.2
Would anybody hint me for the solution?
I tried previously what I could find in Stack… didn’t help
2
Answers
Those packages depend on GDAL, GEOS, and PROJ. In the old days, one needed to install these using system commands. (Since you don’t lay out what has been tried previously, we cannot know if you did any of that spadework.) But my understanding is that the
sf
-package dependencies which is the core of spatial packages, will now orchestrate the installation of those system packages, so you should first try:If that fails (and I’m unable to test whether it will succeed since I have a complete version on my Ubuntu 18.04 system), then search SO on the topic of errors in installation of
sf
andrgdal
.This website: https://r-spatial.github.io/sf/ recommends this script for system-mediated installation of those dependencies (obviously from a Terminal session):
As you are on Ubuntu 22.04, you can rely on binaries from r2u. Earlier today I just replied to someone on Mastodon with a similar question for just
sf
and prepared a demo in a quick mp4 I cannot post here because of the file size limit but you can read the post with its demo or just look at the mp4 video demo.It would be the same for your issue — on an Ubuntu system where the r2u
apt
repo has been added andbspm
been added you just doI just did in a
r2u
container and it took all of 25 seconds to install a total of 70 binary .deb packages.Edit: To illustrate, for example for package
sf
we automatically resolve towhich shows exactly which graphics libraries are needed and supplied:
and ditto with the needed R packages
each of which of course bring their dependencies in. And best of all: no compilation, no failure, no errors, and near-immediate access.
Give it a try, you can even try
r2u
in your browser thanks to https://gitpod.io (if you sign up, eg with your github id). See the link at the end of https://eddelbuettel.github.io/r2u/