Compose Rasters into zonal summaries, indicated by another raster.
Usage
compose(x, y, ...)
# S4 method for Database,Cropmaps
compose(x, y, variablex, variabley, fun = "mean", ...)
Arguments
- x
S4 object. The product of interest.
- y
S4 object. The product determining the zones.
- ...
extra arguments passed to
fun
.- variablex
character. The variable of product
x
.- variabley
character. The variable of product
y
.- fun
character or function. The function to apply for the summaries.
Value
A data.frame with the zonal summaries. The data.frame is also saved in the cronus database in .csv format.
Examples
if (FALSE) {
# Define required variables
region <- Region(name = "nebraska", type = "us state",
div = c(country = "United States", state = "Nebraska"))
date <- date_seq("2002-01-01", "2002-12-31")
## Daymet
# Create objects
x <- new("Daymet", region = region, date = date)
y <- new("Cropmaps", region = region, date = date)
# Compose
a <- compose(x, y, variablex = "gdd", variabley = "cdl_default", fun = "mean")
b <- compose(x, y, variablex = "prcp", variabley = "cdl_default", fun = "mean")
## MOD09GA
# Create objects
x <- new("Mod09ga", region = region, date = date)
y <- new("Cropmaps", region = region, date = date)
a <- compose(x, y, variablex = "ndvi_smooth_wt1", variabley = "cdl_recoded", fun = "mean")
}