| Title: | Tidy 'STAC' Workflows for R |
|---|---|
| Description: | Wraps the 'rstac' package with a pipe-friendly, tidy API. All results return 'tibbles' instead of nested lists. Ships with a catalog registry of known 'STAC' endpoints including Planetary Computer, Earth Search, and 'USGS', while supporting any 'STAC' API URL. |
| Authors: | Chris Lyons [aut, cre, cph] |
| Maintainer: | Chris Lyons <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-12 08:05:09 UTC |
| Source: | https://github.com/chrislyonsky/stacr |
Tests whether a network connection to a STAC endpoint is available.
Used in @examplesIf guards for network-dependent examples.
has_internet()has_internet()
TRUE if an internet connection is available, FALSE otherwise.
has_internet()has_internet()
Returns a tibble of known STAC API endpoints bundled with the package. Includes Planetary Computer, Earth Search, and USGS catalogs.
stac_catalogs()stac_catalogs()
A tibble::tibble with columns:
Human-readable catalog name.
Root URL of the STAC API endpoint.
Organization providing the catalog.
stac_catalogs()stac_catalogs()
Queries a STAC API endpoint and returns available collections as a tidy
tibble. Wraps rstac::collections() with tidy output.
stac_collections(url)stac_collections(url)
url |
Character. Root URL of a STAC API endpoint
(e.g., |
A tibble::tibble with one row per collection and columns:
Collection identifier.
Human-readable title.
Collection description.
stac_collections("https://earth-search.aws.element84.com/v1")stac_collections("https://earth-search.aws.element84.com/v1")
Downloads assets from STAC items returned by stac_search() or
stac_items(). Wraps rstac::assets_download() with tidy output.
stac_download(items, assets = NULL, output_dir = tempdir(), overwrite = FALSE)stac_download(items, assets = NULL, output_dir = tempdir(), overwrite = FALSE)
items |
An rstac |
assets |
Character vector. Asset names to download (e.g.,
|
output_dir |
Character. Directory where files are saved.
Defaults to |
overwrite |
Logical. Overwrite existing files? Defaults to |
The rstac items object (invisibly) with assets downloaded to
output_dir. Downloaded file paths can be retrieved with
rstac::assets_url().
# Search for items first items <- stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 1 )# Search for items first items <- stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 1 )
Retrieves items from a specific collection in a STAC API endpoint and
returns them as a tidy tibble. Wraps rstac::items() with tidy output.
stac_items(url, collection, limit = 100L)stac_items(url, collection, limit = 100L)
url |
Character. Root URL of a STAC API endpoint
(e.g., |
collection |
Character. The collection ID to list items from. |
limit |
Integer. Maximum number of items to return. Defaults to 100. |
A tibble::tibble with one row per item and columns:
Item identifier.
Collection the item belongs to.
Acquisition datetime as a character string.
Bounding box as a numeric list column.
GeoJSON geometry as a list column.
Character vector of available asset names.
stac_items( url = "https://earth-search.aws.element84.com/v1", collection = "sentinel-2-l2a", limit = 5 )stac_items( url = "https://earth-search.aws.element84.com/v1", collection = "sentinel-2-l2a", limit = 5 )
Creates an interactive 'leaflet' map showing the spatial footprints of
STAC items returned by stac_search() or stac_items(). Requires the
'leaflet' and 'sf' packages to be installed.
stac_map(items)stac_map(items)
items |
A tibble::tibble of STAC items as returned by
|
A leaflet htmlwidget object.
items <- stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 ) stac_map(items)items <- stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 ) stac_map(items)
Searches a STAC API endpoint for items matching the given filters and
returns results as a tidy tibble. Wraps rstac::stac_search() with
tidy output.
stac_search( url, collections = NULL, bbox = NULL, datetime = NULL, limit = 100L )stac_search( url, collections = NULL, bbox = NULL, datetime = NULL, limit = 100L )
url |
Character. Root URL of a STAC API endpoint
(e.g., |
collections |
Character vector. Collection IDs to search within. |
bbox |
Numeric vector of length 4: |
datetime |
Character. Date/time filter as a single datetime or
range (e.g., |
limit |
Integer. Maximum number of items to return. Defaults to 100. |
A tibble::tibble with one row per item and columns:
Item identifier.
Collection the item belongs to.
Acquisition datetime as a character string.
Bounding box as a numeric list column.
GeoJSON geometry as a list column.
Character vector of available asset names.
stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 )stac_search( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 )
Like stac_search() but returns the raw rstac doc_items object
instead of a tibble. Useful as input for stac_download() and
stac_to_cube().
stac_search_raw( url, collections = NULL, bbox = NULL, datetime = NULL, limit = 100L )stac_search_raw( url, collections = NULL, bbox = NULL, datetime = NULL, limit = 100L )
url |
Character. Root URL of a STAC API endpoint
(e.g., |
collections |
Character vector. Collection IDs to search within. |
bbox |
Numeric vector of length 4: |
datetime |
Character. Date/time filter as a single datetime or
range (e.g., |
limit |
Integer. Maximum number of items to return. Defaults to 100. |
An rstac doc_items object.
raw <- stac_search_raw( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 1 )raw <- stac_search_raw( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 1 )
Bridges STAC search results to 'gdalcubes' for raster data cube analysis. Requires the 'gdalcubes' package to be installed.
stac_to_cube(items, asset_names = NULL, ...)stac_to_cube(items, asset_names = NULL, ...)
items |
An rstac |
asset_names |
Character vector. Asset names to include in the
image collection (e.g., |
... |
Additional arguments passed to
|
A gdalcubes image collection object.
raw <- stac_search_raw( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 ) cube <- stac_to_cube(raw, asset_names = c("red", "green", "blue"))raw <- stac_search_raw( url = "https://earth-search.aws.element84.com/v1", collections = "sentinel-2-l2a", bbox = c(-84.5, 38.0, -84.3, 38.2), limit = 5 ) cube <- stac_to_cube(raw, asset_names = c("red", "green", "blue"))