raster2magpie: Convert raster data to MAgPIE object

Description Usage Arguments Value Author(s) Examples

View source: R/raster2magpie.R

Description

Raster data (layers, bricks or stacks) from the raster package is converted to a MAgPIE object. In the case of bricks and stacks different data dimensions are created for the different layers. Data should be in lat/long with a 0.5x0.5 degree resolution, and have at least the extent of MAgPIE data (-180,180,-56,83.5)

Usage

1
raster2magpie(x, detect_years=TRUE)

Arguments

x

A raster object

detect_years

The function can try to detect years (4 digit numbers) in the names of the raster, and use them as the temporal dimension

Value

A MAgPIE object with the data of the raster at the geographic center of each MAgIE cell

Author(s)

Ulrich Kreidenweis

Examples

1
2
3
4
5
6
7
8
## Not run: 
r <- raster::raster()
raster::res(r) <- 0.5
raster::values(r) <- 1:(raster::ncell(r))
m <- raster2magpie(r)
head(m)

## End(Not run)

pik-piam/geodata documentation built on Nov. 5, 2019, 12:21 a.m.