# NOT RUN {
### SpatRaster
r <- rast(nrow=18, ncol=36)
v <- 1:ncell(r)
v[200:400] <- NA
values(r) <- v
# summed area in km2
expanse(r, unit="km")
r <- rast(ncol=90, nrow=45, ymin=-80, ymax=80)
m <- project(r, "+proj=merc")
expanse(m, unit="km")
expanse(m, unit="km", transform=FALSE)
### SpatVector
v <- vect(system.file("ex/lux.shp", package="terra"))
a <- expanse(v)
a
sum(a)
# }
Run the code above in your browser using DataLab