mergeGrid | R Documentation |
Merge multiple grids in space (latitude and longitude).
mergeGrid(..., aggr.fun = list(FUN = "mean", na.rm = TRUE))
... |
Input grids to be merged. |
aggr.fun |
Aggregation function to the intersection areas among grids. The default option computes the mean aggr.fun = list(FUN = "mean", na.rm = TRUE). |
Aggregation function definition
The aggregation functions are specified in the form of a named list of the type FUN = "function", ...
, where
...
are further arguments passes to FUN. This allows for a flexible definition of aggregation functions, that are
internally passes to tapply
. Note that the name of the function is indicated as a character string.
A single grid result of merging the input grids.
J. BaƱo-Medina, M. Iturbide
require(climate4R.datasets)
# We load the dataset (temperature)
data("CFS_Iberia_tas")
# We take a look at the domain of the dataset
library(visualizeR)
spatialPlot(climatology(CFS_Iberia_tas),backdrop.theme = "coastline")
getGrid(CFS_Iberia_tas)
# We divide the dataset in 2 regions
region1 <- subsetGrid(CFS_Iberia_tas,lonLim = c(-10,-6), latLim = c(36,38))
spatialPlot(climatology(region1),backdrop.theme = "coastline")
region2 <- subsetGrid(CFS_Iberia_tas,lonLim = c(-5,3), latLim = c(37,43))
spatialPlot(climatology(region2),backdrop.theme = "coastline")
# We merge the regions and apply the mean function to the intersection
merged <- mergeGrid(region1,region2,aggr.fun = list(FUN = "mean", na.rm = TRUE))
spatialPlot(climatology(merged),backdrop.theme = "coastline")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.