Open philament opened 4 years ago
I second this. Very excellent software all around. Hats off.
However, I wonder how simple it would be to implement? Does GEE export time series data?
What might be a viable workaround?
lapply
is a bit messy due the need to select options for each loops...
All in all, good work! Look forward to further developments!
Got a solution. Ugly, but works. Use lapply
, as suggested above. Might need testCase = "n"
.
Here's an example, grabs weekly data, for each year, over a 10 year time-span; 12 hour run-time:
## set date range and temporal granularity
timeSeq <- seq(as.Date('2008-01-01'),as.Date('2019-01-01'), ## define date range
by = 8) ## define temporal granularity (# of days to include per period)
## setup function
processGEE <- function(datasetID=NA, timeSeq=NA, scaleFactor=NA, runTest = F){ ## input time sequence
if(runTest == T) {i=1:3 ## for debug
} else {i=1:(length(timeSeq) - 1)} ## let loop duration for sequence n
lapply(i, function(i) {
ee_grab(data = ee_data_collection(datasetID = datasetID, ## select dataset from web
spatialReducer = "mean", ## select spatial aggregator function
temporalReducer = "mode", ## select temporal aggregation
## average, cummulative, max, min... other prob not relevan?
timeStart = as.character(timeSeq[[i]]),
timeEnd = as.character(timeSeq[[i+1]]),
resolution = scaleFactor),
targetArea = "NUTS-DATA/NUTS_RG_60M_2016_4326_LEVL_3.geojson", ## download from Euronuts website
testCase = "n"
) %>% as.data.frame()
}) %>% Reduce(merge, .) %>% st_as_sf()
}
Is it possible to specify that I want to request time series from a collection rather than temporal averages? Running something like
always returns the average over the entire time period (presumably because
temporalReducer = "mean"
by default). How do I average only in space but not in time? I.e. I want to average over my regions of interest for each image but return the time series of that for the specified period.