r <- rast()
# aggregated SpatRaster, no values
ra <- aggregate(r, fact=10)
values(r) <- runif(ncell(r))
# aggregated raster, max of the values
ra <- aggregate(r, fact=10, fun=max)
# multiple layers
s <- c(r, r*2)
x <- aggregate(s, 20)
## SpatVector
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
va <- aggregate(v, "ID_1")
plot(va, "NAME_1", lwd=5, plg=list(x="topright"), mar=rep(2,4))
lines(v, lwd=3, col="light gray")
lines(va)
text(v, "ID_1", halo=TRUE)
Run the code above in your browser using DataLab