diff --git a/NEWS.md b/NEWS.md index 6dc420b..2ff66e2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # rsi (development version) +* `get_stac_data()` no longer fails if downloading an asset fails, but instead + returns a raster with all available data. This may still fail when a single + asset fails to download while downloading multiple assets combined within a + single raster; please open an issue if this happens to you! Thanks to + @laurenkwick in #74 (#75). + # rsi 0.2.1 * `calculate_indices()` gains several new arguments: diff --git a/R/download.R b/R/download.R index 45a83c9..b9cf139 100644 --- a/R/download.R +++ b/R/download.R @@ -128,7 +128,7 @@ rsi_download_rasters <- function(items, "Failed to download {items$features[[which_item]]$id %||% 'UNKNOWN'} from {items$features[[which_item]]$properties$datetime %||% 'UNKNOWN'}" # nolint ) ) - download_locations[which_item, ] <- NA + download_locations[which_item, ] <<- NA } ) }, @@ -138,7 +138,13 @@ rsi_download_rasters <- function(items, ) } ) - as.data.frame(as.list(stats::na.omit(download_locations))) + out <- stats::na.omit(download_locations) + if (!is.null(na.action(out))) { + na_attr <- na.action(out) + } + out <- as.data.frame(as.list(out)) + attr(out, "na.action") <- na_attr + out } maybe_sign_items <- function(items, sign_function) { diff --git a/R/get_stac_data.R b/R/get_stac_data.R index e1ede88..85b1a11 100644 --- a/R/get_stac_data.R +++ b/R/get_stac_data.R @@ -364,6 +364,9 @@ get_stac_data <- function(aoi, gdal_config_options = gdal_config_options, ... ) + if (!is.null(na.action(download_results))) { + items$features[na.action(download_results)] <- NULL + } # mask if (!is.null(mask_band)) { download_results <- rsi_apply_masks(