Skip to content

Commit

Permalink
Add examples of stretching images
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemahoney218 committed Aug 20, 2024
1 parent d0acb46 commit 7c2c0cf
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 6 deletions.
5 changes: 5 additions & 0 deletions R/get_stac_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@
#' output_filename = tempfile(fileext = ".tif")
#' )
#'
#' landsat_image |>
#' terra::rast() |>
#' terra::stretch() |>
#' terra::plotRGB()
#'
#' # The `get_*_imagery()` functions will download
#' # all available "data" assets by default
#' # (usually including measured values, and excluding derived bands)
Expand Down
11 changes: 10 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ landsat_image <- get_stac_data(
terra::plot(terra::rast(landsat_image))
```

For these common use cases, however, rsi also provides helper functions which
For common data sets, rsi also provides helper functions which
provide most of these arguments for you. For instance, that `get_stac_data()`
call could be as simple as:

Expand All @@ -103,6 +103,15 @@ landsat_image <- get_landsat_imagery(
terra::plot(terra::rast(landsat_image))
```

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:

```{r}
landsat_image |>
terra::rast(lyrs = c("R", "G", "B")) |>
terra::stretch() |>
terra::plotRGB()
```

By default, these functions download data from Microsoft's Planetary Computer
API, using a number of configuration options set in `rsi_band_mapping` objects
provided by the package. You can see these default configuration options by
Expand Down
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ terra::plot(terra::rast(landsat_image))

<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />

For these common use cases, however, rsi also provides helper functions
which provide most of these arguments for you. For instance, that
`get_stac_data()` call could be as simple as:
For common data sets, rsi also provides helper functions which provide
most of these arguments for you. For instance, that `get_stac_data()`
call could be as simple as:

``` r
landsat_image <- get_landsat_imagery(
Expand All @@ -152,6 +152,20 @@ terra::plot(terra::rast(landsat_image))

<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />

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:

``` r
landsat_image |>
terra::rast(lyrs = c("R", "G", "B")) |>
terra::stretch() |>
terra::plotRGB()
```

<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />

By default, these functions download data from Microsoft’s Planetary
Computer API, using a number of configuration options set in
`rsi_band_mapping` objects provided by the package. You can see these
Expand Down Expand Up @@ -188,7 +202,7 @@ indices <- calculate_indices(
terra::plot(terra::rast(indices))
```

<img src="man/figures/README-unnamed-chunk-6-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-7-1.png" width="100%" />

And last but not least, rsi includes a utility for efficiently combining
rasters containing different data about the same location into a
Expand All @@ -206,7 +220,7 @@ raster_stack <- stack_rasters(
terra::plot(terra::rast(raster_stack))
```

<img src="man/figures/README-unnamed-chunk-7-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-8-1.png" width="100%" />

This can be extremely useful as a way to create predictor bricks and
other multi-band rasters from various data sources.
Expand Down
Binary file added man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions man/get_stac_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/rsi-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7c2c0cf

Please sign in to comment.