whichLayers | R Documentation |
Uses Layer metadata to return all Layers with a particular properties. For example only tree Layers, or only evergreen Layers.
whichLayers(x, criteria, return.ids = TRUE)
x |
Either a Field, or a list of Layer objects |
criteria |
A character string to use to select Layers. This compared to every the value of every slot of a Layer object. If one matches, the Layer is inlucded in the return. |
return.ids |
A logical, if TRUE (default) then return the the id of the Layers, if FALSE return the entire Layer objects |
Either a vector of characters (the ids of the Layers) or a list of Layer object (depending on argument return.ids)
Matthew Forrest matthew.forrest@senckenberg.de
## List Layers from a list of Layer objects
# make a list of Layers for selecting from
layer.list <- GUESS@predefined.layers
print(layer.list)
# return Tree, Grass, Evergreen and Tropical PFTs
whichLayers(layer.list, criteria = "Tree")
whichLayers(layer.list, criteria = "Grass")
whichLayers(layer.list, criteria = "Evergreen")
whichLayers(layer.list, criteria = "Tropical")
# return Tropical PFTs as a list of Layers objects (not just the ids)
whichLayers(layer.list, criteria = "Tropical", return.ids = FALSE)
## List Layers from a Field object
# Load a multi-Layer (one layer per-PFT) Field from the example data
run.dir <- system.file("extdata", "LPJ-GUESS_Runs", "CentralEurope", package = "DGVMTools")
test.Source <- defineSource(id = "LPJ-GUESS_Example", dir = run.dir, format = GUESS)
test.Field.perLayer <- getField(source = test.Source, quant = "lai")
# Perform the same examples as above but with the Field instead of a list of Layers objects
# return Tree, Grass, Evergreen and Tropical Layers
whichLayers(test.Field.perLayer, criteria = "Tree")
whichLayers(test.Field.perLayer, criteria = "Grass")
whichLayers(test.Field.perLayer, criteria = "Evergreen")
whichLayers(test.Field.perLayer, criteria = "Tropical")
# return Tropical PFTs as a list of Layers objects (not just the ids)
whichLayers(test.Field.perLayer, criteria = "Tropical", return.ids = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.