addLocation: addLocation

View source: R/addLocation.R

addLocationR Documentation

addLocation

Description

Function translates (if possible) cell numbers into coordinates or coordinates into cell numbers and adds them to the spatial dimension of the object.

Usage

addLocation(x, fillMissing = NULL, naCellNumber = 0, format = "both")

Arguments

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.

Value

magpie object with added spatial subdimensions

Author(s)

Jan Philipp Dietrich, Felicitas Beier, Michael Crawford

Examples


 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)


pik-piam/magpiesets documentation built on April 22, 2024, 3:34 p.m.