Query a STAC source
Sign STAC items retrieved from the Microsoft Planetary Computer (MPC)
Generate a Sentinel 2 stac collection doc_imes object
Generate a Harmonized Landsat Sentinel (HLS) stac collection doc_imes object
Generate a Sentinel 1 stac collection doc_items object
Usage
stac_query(bbox, stac_source, collection, start_date, end_date, limit = 999)
sign_planetary_computer(items, subscription_key = Sys.getenv("MPC_TOKEN"))
sentinel2_stac_query(
bbox,
start_date,
end_date,
assets = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B11",
"B12", "SCL"),
max_cloud_cover = 10,
stac_source = "https://planetarycomputer.microsoft.com/api/stac/v1/",
collection = "sentinel-2-l2a",
mpc_sign = TRUE,
limit = 999
)
hls_stac_query(
bbox,
start_date,
end_date,
assets = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B10",
"B11", "B12", "Fmask"),
max_cloud_cover = 10,
stac_source = "https://cmr.earthdata.nasa.gov/stac/LPCLOUD/",
collection = c("HLSS30_2.0", "HLSL30_2.0"),
limit = 999
)
sentinel1_stac_query(
bbox,
start_date,
end_date,
assets = c("hh", "hv", "vh", "vv"),
orbit_state = c("descending", "ascending"),
stac_source = "https://planetarycomputer.microsoft.com/api/stac/v1/",
collection = c("sentinel-1-rtc", "sentinel-1-grd"),
mpc_sign = TRUE,
limit = 999
)
Arguments
- bbox
A numeric vector of the bounding box (length 4) in lat/long
- stac_source
A character string of the STAC source
- collection
A character string of the collection to query
- start_date
The start date for the query
- end_date
The end date for the query
- limit
The number of items to return
- items
A STACItemCollection.
- subscription_key
Optionally (but strongly recommended), a subscription key associated with your MPC account. At the time of writing, this is required for downloading Sentinel 1 RTC products, as well as NAIP imagery. This key willb be automatically used if the environment variable
MPC_TOKEN
is set.- assets
A character vector of the asset names to include
- max_cloud_cover
A numeric value of the maximum cloud cover percentage
- mpc_sign
A logical indicating whether to sign the items using the Planetary Computer API's signing method (only required if using the Planetary Computer STAC API).
- orbit_state
A character vector of the orbit state to filter by. Both arguments are allowed however - consider carefully the implications of retaining both orbits if you intend to composite the data.
Details
In order to access HLS data you will need a NASA Earthdata account. You can
create one at https://urs.earthdata.nasa.gov/users/new. Once you have
an account, you can set your credentials using the earthdatalogin
package
as shown in the examples.
Examples
if (FALSE) { # interactive()
s2_its <- stac_query(
bbox = c(-12.386, -37.214, -12.186, -37.014),
stac_source = "https://planetarycomputer.microsoft.com/api/stac/v1/",
collection = "sentinel-2-l2a",
start_date = "2023-01-01",
end_date = "2023-01-31",
limit = 10
)
mpc_singed <- sign_planetary_computer(s2_its)
}
if (FALSE) { # interactive()
sentinel2_stac_query(
bbox = c(-12.386, -37.214, -12.186, -37.014),
start_date = "2023-01-01",
end_date = "2023-01-31",
max_cloud_cover = 10,
assets = c("B02", "B03", "B04", "B08", "SCL")
)
}
if (FALSE) { # interactive()
hls_query <- hls_stac_query(
c(144.130, -7.725, 144.470, -7.475),
start_date = "2023-01-01",
end_date = "2023-12-31",
assets = c("B04", "B03", "B02", "Fmask"),
collection = "HLSS30_2.0",
max_cloud_cover = 35
)
# in order to download these items (or call further vrt_x functions) you
# will first need to set your credentials. The easiest way to do this is with
# the `earthdatalogin` package. First set your EARTHDATA_USER and
# EARTHDATA_PASSWORD environment variables and then run the following command:
earthdatalogin::edl_netrc(
username = Sys.getenv("EARTHDATA_USER"),
password = Sys.getenv("EARTHDATA_PASSWORD")
)
}
if (FALSE) { # interactive()
sentinel1_stac_query(
bbox = c(-12.386, -37.214, -12.186, -37.014),
start_date = "2023-01-01",
end_date = "2023-01-31",
assets = "vv"
)
}