I am grateful to be using MODISTools to download image matches in time and space. Specifically, MODISTools is looking up leaf area index for a million related observations made by a different satellite. As warned, the NASA server times out regularly.
When that happens I would like r to catch the error, wait briefly (if even needed), then try again. I know the wait does not need to be more than a few seconds because I am running multiple instances, and only one or two of them time out at once. Once the error is detected, processing could resume by retrying the same step, or, with essentially the same effect, by restarting the sequence pasted below. Is there a straightforward way to do this? If it involves invoking server commands from r, please write your answer for an ignoramus!
Here's an example, though without hitting a time-out it won't illustrate much. For simplicity I show fixed location and dates. In the real run they derive from other fields in the my.chunk dataframe.
look.these.up <- which(is.na(my.chunk$lai))
for (m.obs in look.these.up) {
junk <- mt_subset(product = "MOD15A2H", lon = 5, lat = 5,
start = "2017-01-01", end = "2017-01-08")
my.chunk$lai[m.obs] <- junk$data[, "data"][5]
}