I was able to install terra
on Google Colab using the code below. It did take about 5-10 minutes for the library to install.
In Google Colab, select "Runtime", "Change runtime type" and select "R" under "Runtime type".
Install terra
per the instructions on the module's GitHub page:
install.packages("Rcpp")
Sys.setenv("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "true")
remotes::install_github("rspatial/terra")
#read in packages
library(terra)
- Test that the module is imported and working, the code block below is from the rspatial.org site:
## terra 1.7.36
# create an empty SpatRaster
r <- rast(ncol=10, nrow=10)
# assign values to cells
values(r) <- 1:ncell(r)
s <- r + 10
s <- sqrt(s)
s <- s * r + 5
values(r) <- runif(ncell(r))
r <- round(r)
r <- r == 1
r
Output is below:
class : SpatRaster
dimensions : 10, 10, 1 (nrow, ncol, nlyr)
resolution : 36, 18 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84
source(s) : memory
name : lyr.1
min value : FALSE
max value : TRUE
Additional code block:
x <- rast(ncol=36, nrow=18, xmin=-1000, xmax=1000, ymin=-100, ymax=900)
res(x)
## [1] 55.55556 55.55556
res(x) <- 100
res(x)
Output:
55.555555555555655.5555555555556
100100