mergeGrid: Merge multiple grids in space

View source: R/mergeGrid.R

mergeGridR Documentation

Merge multiple grids in space

Description

Merge multiple grids in space (latitude and longitude).

Usage

mergeGrid(..., aggr.fun = list(FUN = "mean", na.rm = TRUE))

Arguments

...

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).

Details

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.

Value

A single grid result of merging the input grids.

Author(s)

J. BaƱo-Medina, M. Iturbide

Examples


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")


SantanderMetGroup/transformeR documentation built on Nov. 25, 2024, 1:25 p.m.