Skip to content

Commit

Permalink
Survive past failed download when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemahoney218 committed Jul 8, 2024
1 parent 315cc62 commit be0da7b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 8 additions & 2 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
},
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions R/get_stac_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit be0da7b

Please sign in to comment.