Reputation: 51
I'm trying to install the R package rgdal in my colab session. I know it needs the dependency GDAL to run, and normally this isn't a problem. I can find lots of help installing it using normal linux commands, but can't find anything on how I can install it from an R session.
This is my code if it helps:
install.packages("rgdal", dependencies=TRUE,repos='http://cran.rstudio.com/')
Warning message in install.packages("rgdal", dependencies = TRUE, repos = "http://cran.rstudio.com/"):
“installation of package ‘rgdal’ had non-zero exit status”
Does anyone know if there's a way to install GDAL using R commands? Or a way to use magic commands like %%Shell in collab with an R Kernel? I'm fairly new to colab, but want my students to be able to run a script using rasters in colab using R.
Cheers
Upvotes: 1
Views: 588
Reputation: 188
I think that now the installation of rgdal
package is straightforward in a Colab R Kernel notebook:
install.packages("rgdal")
library(rgdal)
However, you may consider using pckage sf
instead of rgdal
, as rgdal
will stop working on December 2023. To install sf
in Colab R Kernel you should use the following code:
system("apt-get -y update")
system("apt-get install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev")
install.packages("sf")
library(sf)
Upvotes: 1
Reputation: 51
After lots and lots of painful searching I found the answer:
system("sudo apt-get install libgdal-dev libproj-dev")
So R tells colab to install dependencies like normal linux.
Upvotes: 4