Skip to content

Commit dacabe2

Browse files
Prep release
1 parent e0f8133 commit dacabe2

21 files changed

+72
-74
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rsi
22
Title: Efficiently Retrieve and Process Satellite Imagery
3-
Version: 0.3.2
3+
Version: 0.3.1.9001
44
Authors@R: c(
55
person("Michael", "Mahoney", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2402-304X")),

R/calculate_indices.R

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
#' @param output_filename The filename to write the computed metrics to.
3131
#' @inheritParams rlang::args_dots_empty
3232
#' @inheritParams terra::predict
33-
#' @param extra_objects A named list of additional objects to pass to the
33+
#' @param extra_objects A named list of additional objects to pass to the
3434
#' minimal environment that formulas are executed in. For instance, if you
35-
#' need to use the `pmax` function in order to calculate an index, you can
36-
#' make it available in the environment by setting
37-
#' `extra_objects = list("pmax" = pmax)`. Providing extra functionality is
38-
#' inherently less safe than the default minimal environment, and as such always
35+
#' need to use the `pmax` function in order to calculate an index, you can
36+
#' make it available in the environment by setting
37+
#' `extra_objects = list("pmax" = pmax)`. Providing extra functionality is
38+
#' inherently less safe than the default minimal environment, and as such always
3939
#' emits a warning, which you can suppress with `suppressWarnings()`.
4040
#' @param names_suffix If not `NULL`, will be used (with [paste()]) to add a
4141
#' suffix to each of the band names returned.
@@ -63,7 +63,7 @@
6363
#' tempfile(fileext = ".tif")
6464
#' )
6565
#' )
66-
#'
66+
#'
6767
#' # Because of this, formulas which try to use most R functions
6868
#' # will wind up erroring as well:
6969
#' example_indices$formula <- "pmax(VH, VV)"
@@ -74,7 +74,7 @@
7474
#' tempfile(fileext = ".tif")
7575
#' )
7676
#' )
77-
#'
77+
#'
7878
#' # To fix this, pass the objects you want to use to `extra_objects`
7979
#' calculate_indices(
8080
#' system.file("rasters/example_sentinel1.tif", package = "rsi"),
@@ -145,10 +145,11 @@ calculate_indices <- function(raster,
145145
)
146146

147147
if (length(extra_objects)) {
148-
rlang::warn(c(
149-
"Providing extra objects can potentially make it easier for malicious code to impact your system.",
150-
i = "Make sure you closely inspect the formulas you're running, before running them, and understand why they need extra objects!",
151-
i = "This warning can be silenced using `suppressWarnings(..., classes = 'rsi_extra_objects')`"
148+
rlang::warn(
149+
c(
150+
"Providing extra objects can potentially make it easier for malicious code to impact your system.",
151+
i = "Make sure you closely inspect the formulas you're running, before running them, and understand why they need extra objects!",
152+
i = "This warning can be silenced using `suppressWarnings(..., classes = 'rsi_extra_objects')`"
152153
),
153154
class = "rsi_extra_objects"
154155
)

R/get_stac_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ rsi_composite_bands <- function(download_locations,
737737
)
738738
)
739739
} else {
740-
capture.output({
740+
utils::capture.output({
741741
do.call(
742742
terra::mosaic,
743743
list(

R/mask_functions.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ landsat_mask_function <- function(raster,
113113
if (any(c("water", "both") %in% include)) {
114114
masked_bits <- c(masked_bits, list(c(0:5, 9, 11, 13, 15)))
115115
}
116-
117116
} else if (!missing(include)) {
118117
rlang::abort(
119118
"Only one of `include` and `masked_bits` can be specified.",

R/misc.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ build_progressr <- function(n) {
5858
}
5959

6060
#' Default options for GDAL
61-
#'
61+
#'
6262
#' These functions provide useful default options for GDAL functions,
6363
#' making downloading and warping (hopefully!) more efficient for
64-
#' most use cases.
65-
#'
64+
#' most use cases.
65+
#'
6666
#' @returns A vector of options for GDAL commands.
67-
#'
67+
#'
6868
#' @name rsi_gdal_options
6969
#' @export
7070
rsi_gdal_config_options <- function() {

R/query_and_sign.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#' available for your AOI, or to perform cloud filtering prior to downloading
1111
#' assets.
1212
#'
13-
#' @param bbox A `bbox` or `sfc` object, from the sf package, representing the
14-
#' spatial bounding box of your area of interest. This must be in EPSG:4326
15-
#' coordinates (and, if this function is called from within `get_stac_data()`,
13+
#' @param bbox A `bbox` or `sfc` object, from the sf package, representing the
14+
#' spatial bounding box of your area of interest. This must be in EPSG:4326
15+
#' coordinates (and, if this function is called from within `get_stac_data()`,
1616
#' it will be) or else it will be automatically reprojected.
1717
#' @inheritParams get_stac_data
1818
#' @param start_date,end_date Character strings of length 1 representing the

R/stack_rasters.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#' when given a character vector of band names, returns a character vector of
3535
#' the same length containing new band names.
3636
#' @param check_crs Logical: Should this function check that all `rasters` share
37-
#' the same CRS? Set to `FALSE` only if you are entirely confident that rasters
37+
#' the same CRS? Set to `FALSE` only if you are entirely confident that rasters
3838
#' have equivalent CRS definitions, but not identical WKT strings.
3939
#' @param gdalwarp_options Options passed to `gdalwarp` through the `options`
4040
#' argument of [sf::gdal_utils()]. This argument is ignored (with a warning)

README.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ terra::plot(terra::rast(landsat_image))
106106
Note that we've been plotting each band individually so far by calling `terra::plot()`. We could also use `terra::plotRGB()` (after `terra::stretch()`ing the band values) to see what this mosaic of images would look like to the human eye:
107107

108108
```{r}
109-
landsat_image |>
110-
terra::rast(lyrs = c("R", "G", "B")) |>
109+
landsat_image |>
110+
terra::rast(lyrs = c("R", "G", "B")) |>
111111
terra::stretch() |>
112112
terra::plotRGB()
113113
```

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
[![R-CMD-check](https://github.com/Permian-Global-Research/rsi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Permian-Global-Research/rsi/actions/workflows/R-CMD-check.yaml)
99
[![Codecov test
1010
coverage](https://codecov.io/gh/Permian-Global-Research/rsi/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Permian-Global-Research/rsi?branch=main)
11-
[![License:
12-
Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
11+
[![License: Apache
12+
2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
1313
[![Lifecycle:
1414
maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)
1515
[![Project Status: Active – The project has reached a stable, usable
@@ -27,20 +27,17 @@ The goal of rsi is to address several **r**epeated **s**patial
2727
and help avoid **r**epetitive **s**tress **i**njuries. Specifically, rsi
2828
provides:
2929

30-
- An interface to the **R**some – excuse me, [*Awesome* Spectral
31-
Indices
32-
project](https://github.com/awesome-spectral-indices/awesome-spectral-indices),
33-
providing the list of indices directly in R as a friendly tibble,
34-
- A method for efficiently *calculating* those awesome spectral
35-
indices using local rasters, enabling **r**apid **s**pectral
36-
**i**nference,
37-
- A method for downloading STAC data – excuse me, **r**etriving
38-
**S**TAC **i**nformation – from any STAC server, with additional
39-
helpers for downloading Landsat, Sentinel-1, and Sentinel-2 data
40-
from free and public STAC servers providing **r**apid **s**atellite
41-
**i**magery,
42-
- A **r**aster **s**tack **i**ntegration method for combining multiple
43-
rasters containing distinct data sets into a single raster stack.
30+
- An interface to the **R**some – excuse me, [*Awesome* Spectral Indices
31+
project](https://github.com/awesome-spectral-indices/awesome-spectral-indices),
32+
providing the list of indices directly in R as a friendly tibble,
33+
- A method for efficiently *calculating* those awesome spectral indices
34+
using local rasters, enabling **r**apid **s**pectral **i**nference,
35+
- A method for downloading STAC data – excuse me, **r**etriving **S**TAC
36+
**i**nformation – from any STAC server, with additional helpers for
37+
downloading Landsat, Sentinel-1, and Sentinel-2 data from free and
38+
public STAC servers providing **r**apid **s**atellite **i**magery,
39+
- A **r**aster **s**tack **i**ntegration method for combining multiple
40+
rasters containing distinct data sets into a single raster stack.
4441

4542
The functions in rsi are designed around letting you use the tools
4643
you’re familiar with to process raster data using compute that you
@@ -78,7 +75,7 @@ project](https://github.com/awesome-spectral-indices/awesome-spectral-indices):
7875
library(rsi)
7976

8077
spectral_indices()
81-
#> # A tibble: 243 × 9
78+
#> # A tibble: 245 × 9
8279
#> application_domain bands contributor date_of_addition formula long_name
8380
#> <chr> <list> <chr> <chr> <chr> <chr>
8481
#> 1 vegetation <chr [2]> https://gith… 2021-11-17 (N - 0… Aerosol …
@@ -91,7 +88,7 @@ spectral_indices()
9188
#> 8 vegetation <chr [2]> https://gith… 2022-04-08 (N * (… Advanced…
9289
#> 9 water <chr [4]> https://gith… 2021-09-18 4.0 * … Automate…
9390
#> 10 water <chr [5]> https://gith… 2021-09-18 B + 2.… Automate…
94-
#> # ℹ 233 more rows
91+
#> # ℹ 235 more rows
9592
#> # ℹ 3 more variables: platforms <list>, reference <chr>, short_name <chr>
9693
```
9794

@@ -158,8 +155,8 @@ Note that we’ve been plotting each band individually so far by calling
158155
would look like to the human eye:
159156

160157
``` r
161-
landsat_image |>
162-
terra::rast(lyrs = c("R", "G", "B")) |>
158+
landsat_image |>
159+
terra::rast(lyrs = c("R", "G", "B")) |>
163160
terra::stretch() |>
164161
terra::plotRGB()
165162
```
@@ -197,6 +194,7 @@ indices <- calculate_indices(
197194
available_indices,
198195
output_filename = tempfile(fileext = ".tif")
199196
)
197+
#> |---------|---------|---------|---------|=========================================
200198

201199
# Plot the first handful of spatial indices
202200
terra::plot(terra::rast(indices))
@@ -228,7 +226,7 @@ other multi-band rasters from various data sources.
228226

229227
## Contributing
230228

231-
We love contributions\! See our [contribution
229+
We love contributions! See our [contribution
232230
guide](https://github.com/Permian-Global-Research/rsi/blob/main/.github/CONTRIBUTING.md)
233231
for pointers on how to make your contribution as easy to accept as
234232
possible – in particular, consider [opening an

cran-comments.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
This is the seventh CRAN release of rsi, fixing a test error that
2-
arose on CRAN.
1+
This is the eigth CRAN release of rsi, fixing how downloads
2+
handle duplicated asset timestamps and how errors are
3+
handled during merging.
34

45
## R CMD check results
56

10.7 KB
Loading
26.9 KB
Loading
47.5 KB
Loading
41.1 KB
Loading
39.7 KB
Loading

man/get_stac_data.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rsi_download_rasters.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-mask_functions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ test_that("landsat_mask_function arguments work", {
4141
sum(
4242
terra::values(
4343
landsat_mask_function(
44-
terra::rast(boston_landsat),
44+
terra::rast(boston_landsat),
4545
masked_bits = list(
4646
clear_land = c(0:5, 7, 9, 11, 13, 15),
4747
clear_water = c(0:5, 9, 11, 13, 15)
4848
)
4949
)
5050
)
5151
)
52-
)
52+
)
5353
})

tests/testthat/test-misc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ test_that("c works", {
1313
c(rsi::sentinel2_band_mapping$planetary_computer_v1, scl = "scl"),
1414
c(rsi::sentinel2_band_mapping$planetary_computer_v1, "scl")
1515
)
16-
})
16+
})

vignettes/articles/Downloading-data-from-STAC-APIs-using-rsi.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ ashe_landsat <- get_landsat_imagery(
233233
start_date = "2021-06-01",
234234
end_date = "2021-06-30",
235235
output_filename = tempfile(fileext = ".tif")
236-
)
236+
)
237237
238238
ashe_landsat |>
239239
terra::rast() |>
@@ -265,7 +265,7 @@ ashe_no_composite <- get_landsat_imagery(
265265
output_filename = tempfile(fileext = ".tif"),
266266
composite_function = NULL,
267267
mask_function = NULL # otherwise half of these images are blank
268-
)
268+
)
269269
ashe_no_composite |>
270270
lapply(terra::rast) |>
271271
lapply(terra::plot) |>

vignettes/articles/How-can-I-.Rmd

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,21 @@ aoi <- sf::st_point(c(-74.912131, 44.080410))
100100
aoi <- sf::st_set_crs(sf::st_sfc(aoi), 4326)
101101
aoi <- sf::st_buffer(sf::st_transform(aoi, 5070), 1000)
102102
103-
custom_query_function <- function(bbox,
104-
stac_source,
105-
collection,
106-
start_date,
107-
end_date,
108-
limit,
103+
custom_query_function <- function(bbox,
104+
stac_source,
105+
collection,
106+
start_date,
107+
end_date,
108+
limit,
109109
...) {
110-
geometry <- rstac::cql2_bbox_as_geojson(bbox)
110+
geometry <- rstac::cql2_bbox_as_geojson(bbox)
111111
datetime <- rstac::cql2_interval(start_date, end_date)
112-
112+
113113
request <- rstac::ext_filter(
114114
rstac::stac(stac_source),
115-
collection == {{collection}} &&
116-
t_intersects(datetime, {{datetime}}) &&
117-
s_intersects(geometry, {{geometry}}) &&
115+
collection == {{ collection }} &&
116+
t_intersects(datetime, {{ datetime }}) &&
117+
s_intersects(geometry, {{ geometry }}) &&
118118
`eo:cloud_cover` < 50
119119
)
120120
rstac::items_fetch(rstac::post_request(request))
@@ -179,7 +179,7 @@ You want to calculate some indices from this imagery. Specifically, you want to
179179
To do that using `calculate_indices()`, you're going to need to only provide formulas for the indices that can be calculated from your particular data source. We might look at the columns available for filtering from `spectral_indices()`:
180180

181181
```{r}
182-
spectral_indices() |>
182+
spectral_indices() |>
183183
head(1)
184184
```
185185

@@ -204,18 +204,18 @@ However, if you're looking to automatically calculate just the indices that don'
204204
Assuming you used one of the wrapper functions in rsi, like `get_landsat_data()` or `get_sentinel2_data()`, your raster bands should automatically be named to match the band names used in the ASI project. That means we can pass the names of your raster directly to `filter_bands()`:
205205

206206
```{r}
207-
filter_bands(bands = names(terra::rast(our_imagery))) |>
207+
filter_bands(bands = names(terra::rast(our_imagery))) |>
208208
head(1)
209209
```
210210

211211
And we can pass the outputs of that function to `calculate_indices()` to only calculate this subset of indices:
212212

213213
```{r}
214214
calculate_indices(
215-
our_imagery,
216-
filter_bands(bands = names(terra::rast(our_imagery))),
217-
output_filename = tempfile(fileext = ".tif")
218-
) |>
219-
terra::rast() |>
215+
our_imagery,
216+
filter_bands(bands = names(terra::rast(our_imagery))),
217+
output_filename = tempfile(fileext = ".tif")
218+
) |>
219+
terra::rast() |>
220220
terra::plot()
221221
```

0 commit comments

Comments
 (0)