Funcion 2. 'SpatRaster'

library(terra)
## terra version 1.0.10
r <- rast(ncol=10, nrow=10, xmin=-78.975, xmax=-66.8695, ymin=-4.2175, ymax=12.4457)
values(r) <- (1:100)
values(r) <- 1:ncell(r)

longitude <- c(-78.9750, -77.4611, -77.3539, -71.6773, -71.3386, -73.3750, -72.0794, -67.4654, -66.8695, -67.4080, -69.8495, -69.9429, -70.7126, -71.0524, -73.0848 )
latitude <- c(1.6271, 5.5567, 8.6488, 12.4457, 11.8639, 9.1760, 7.0755, 6.1585, 1.2356, 2.2327, 1.7139, -4.2175, -3.7956, -2.7418, -2.2894)
lonlat <- cbind(longitude, latitude)
crdref = '+proj=longlat +datum=WGS84'
pols <- vect(lonlat, type="polygons", crs=crdref)

plot(r)
plot(pols, las=1, add = T)

EMPAQUETAR

r2 <- sqrt(r)
r3  <- r - r2
r4 <- r3 - r2
s <- c(r, r2, r3, r4)
plot(s)