View source: R/as.SpatRaster.R
as.SpatRaster | R Documentation |
Convert magclass object to a SpatRaster object. Requires the terra package.
as.SpatRaster(x, res = NULL)
x |
MAgPIE object |
res |
spatial data resolution. If not provided it will be guessed. |
A SpatRaster object
Jan Philipp Dietrich
getCoords
if (requireNamespace("terra", quietly = TRUE)) {
r <- terra::rast(ncols = 360, nrows = 180, nl = 4)
r[85:89, 176:179] <- (1:20 %*% t(1:4))
r[15:19, 76:79] <- (10 + 1:20 %*% t(1:4))
names(r) <- c("y2000..bla", "y2001..bla", "y2000..blub", "y2001..blub")
m <- as.magpie(r)
r2 <- as.SpatRaster(m)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.