Pure builders for the building blocks of a STAC Item. None touch disk; use
stac_save() to persist.
new_properties(): assembles an itempropertieslist.new_asset(): creates a single STACAsset.new_item(): creates an in-memoryItem(a GeoJSONFeature).add_items(): links one or more items into a collection, updating the collection links and spatio-temporal extent, and returns the collection.
STAC requires every item to carry a datetime. When you describe a time
range instead of a single instant, supply start_datetime and end_datetime
and omit datetime; new_properties() then records datetime as null, as
the specification mandates. add_items() derives the collection's temporal
extent from the range (or from datetime when only that is given).
Usage
new_properties(
description = NULL,
datetime = NULL,
start_datetime = NULL,
end_datetime = NULL,
start_date = NULL,
end_date = NULL,
...
)
new_asset(href, title = NULL, roles = list("data"), ...)
new_item(
id,
bbox,
geometry = NULL,
properties = new_properties(),
assets = list(),
collection = NULL,
stac_version = "1.0.0",
...
)
add_items(collection, items)Arguments
- description
A
characterdescription.- datetime
A
characterRFC 3339 datetime, orNULL. Recorded asnullwhen omitted alongside astart_datetime/end_datetimerange.- start_datetime
A
characterRFC 3339 start datetime, orNULL.- end_datetime
A
characterRFC 3339 end datetime, orNULL.- start_date
A
characterstart date, orNULL.- end_date
A
characterend date, orNULL.- ...
Additional named fields. See details for each function.
- href
A
characterasset target (path or URL).- title
A
charactertitle.- roles
A
listof asset roles. Defaults tolist("data").- id
A
characteridentifier for the item.- bbox
A numeric vector
c(xmin, ymin, xmax, ymax).- geometry
A GeoJSON geometry
list. IfNULL, it is derived frombboxviaas_geometry().- properties
A
listof item properties, e.g. fromnew_properties().- assets
A named
listof assets, e.g. fromnew_asset().- collection
For
add_items(), thedoc_collectionto link items into. Fornew_item(), an optionaldoc_collectionorcharactercollection id recorded as the item's top-levelcollectionfield. STAC requires this field whenever the item carries acollectionlink (as items built here always do); when omitted,stac_save()stamps it from thecollectionit is given.- stac_version
A
characterSTAC version. Defaults to"1.0.0".- items
A single
doc_item, or alistofdoc_itemobjects, to link into the collection.
Value
new_properties(): alistof properties.new_asset(): adoc_assetobject describing an asset.new_item(): adoc_itemobject.add_items(): the updateddoc_collection.
Examples
props <- new_properties(datetime = "2020-01-01T00:00:00Z")
asset <- new_asset("data.tif", title = "Data")
item <- new_item(
id = "item-1",
bbox = c(-50, -10, -49, -9),
properties = props,
assets = list(data = asset)
)
item$type
#> [1] "Feature"
col <- new_collection("col", "Collection", "Example")
col <- add_items(col, item)
col$extent$spatial$bbox[[1]]
#> [1] -50 -10 -49 -9
