addLocation | R Documentation |
Function translates (if possible) cell numbers into coordinates or coordinates into cell numbers and adds them to the spatial dimension of the object.
addLocation(x, fillMissing = NULL, naCellNumber = 0, format = "both")
x |
magpie object to be enriched with spatial information. Currently only works for 0.5 degree data sets with 59199 or 67420 cells or a subset of it. |
fillMissing |
if NULL cells missing from the total 59199 are just being ignore. If set to a value missing cells will be added with this value (e.g. all set to 0 if fillMissing is 0) |
naCellNumber |
number or string given as cell number for cells which do not have an assigned cell number in the 59199 mapping |
format |
either "both" or "iso.grid". When set to "iso.grid", the function will remove the pre-existing spatial dimensions after adding the coordinates' sorted iso.grid location. This argument is ignored for input objects initially containing iso.grid and LPJ datasets. |
magpie object with added spatial subdimensions
Jan Philipp Dietrich, Felicitas Beier, Michael Crawford
map <- Cell2Country()
x <- y <- z <- population_magpie
getCoords(x) <- map[100:109, c("lon", "lat")]
getItems(x, "i") <- NULL
addLocation(x)
getCoords(y) <- map[100:109, c("lon", "lat")]
getItems(y, "i") <- NULL
addLocation(y, format = "iso.grid")
getCells(z) <- map$celliso[100:109]
addLocation(z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.