This function allows the user to pass a previously created get_*() object to get a time series from a collection, e.g. banding/toBands. This uses the ee_extract function from rgee.
band(
data,
geeFC = NULL,
scale,
band = NULL,
temporal = "yearly",
lazy = FALSE,
fun = ee$Reducer$median(),
variable = NULL,
ggplot = FALSE,
save.plot = F
)
A previously created get_* object
A known GEE FeatureCollection or asset, e.g. "USGS/WBD/2017/HUC12"
numeric
value indicating what to reduce the regions by, e.g. 800 (m) default.
A character
indicating what bands/type to use when you have more than one.
A character
indicating what temporal filter to use on the collection, e.g. 'yearly' (default), 'monthly', 'year_month', 'all'.
logical
whether to run a 'sequential' future in the background or not.
A earth engine reducer, e.g. ee$Reducer$median() (default).
character
indicating what to facet ggplot by. Need to know ahead of time.
logical
TRUE/FALSE. Whether to print side-effect ggplot. See details.
logical
TRUE/FALSE. Whether to save the plot in a list, e.g. data + ggplot.
A data.frame
and a side-effect plot (if ggplot = TRUE); unless using save.plot
then a list with data.frame
and ggplot.
Goal is to add more capabilities to this function in the future by using map() server-side, e.g. monthly and annual filters. Faster with points or centroids of polygons. If lazy is TRUE, the function will be run in the background.
if (FALSE) {
# Load Libraries
library(rgee)
rgee::ee_intialize()
library(exploreRGEE)
# Bring in data
huc <- exploreRGEE::huc
ld8 <- get_landsat(huc, method = 'ld8', startDate = '2014-01-01',
endDate = '2018-12-31', c.low = 6, c.high = 11)
# without plotting save to object
ld8_ts <- ld8 %>% band(scale = 30, band = 'NDVI')
# with plotting as side-effect
ld8 %>% band(scale = 30, band = 'NDVI', ggplot = TRUE, variable = 'name')
# save both plot and data
ld8_ts <- ld8 %>% band(scale = 30, band = 'NDVI',
ggplot = TRUE, variable = 'name',
save.plot = TRUE)
}