Description for selectors for specific input types.
When specifying input types ‘location’, ‘country’, ‘countryRegion’, ‘countryRegionCRS’, ‘CRS’, ‘crsBbox’ or ‘stac_asset[]’, selectors are automatically created that facilitate the selection of those inputs. After being selected, those inputs appear in the input.json of the script or pipeline as objects with various parameters that will be available when loading then in R, Python or Julia.
For example, the ‘location’ selector allows the user to define a bounding box by choosing a country, region and coordinate reference system. Here is an example of an object created through the selection of the Putumayo department in Colombia, in the Bogota 1975 / Colombia West zone reference system:
bbox:
- 983337
- 428305
- 1360903
- 659616
CRS:
name: Bogota 1975 / Colombia West zone
authority: EPSG
code: 21896
proj4Def: >-
+proj=tmerc +lat_0=4.59904722222222 +lon_0=-77.0809166666667 +k=1
+x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m
+no_defs +type=crs
unit: metre
bbox:
- -79.1
- 0.03
- -75.58
- 10.21
country:
englishName: Colombia
ISO3: COL
region:
regionName: Putumayo Department
regionGID: COL.24_2
countryEnglishName: ColombiaHere is the meaning of each key.
| Key name | Section | Description |
|---|---|---|
| bbox | bbox | Array containing the minimum x, minimum y, maximum x, maximum y coordinates (in that order) of the bounding box, in units of the selected CRS. |
| name | CRS | Plain text name of the coordinate reference system selected. |
| authority | CRS | Authority associated with the code of the reference system. Usually EPSG or ESRI. For example EPSG` for ‘EPSG:4326’. |
| code | CRS | Code associated with the authority of the reference system. Usually a 4 or 5 digit integer. For example 4326`for EPSG:4326 |
| proj4Def | CRS | Proj4 string definition of the CRS. |
| wktDef | CRS | Well Known text definition of the CRS, when available. |
| unit | CRS | units associated with CRS. Usually meter, degree, or feet |
| CRSBboxWGS84 | CRS | The bounding box covered by this coordinate reference system, in latitude, longitude, WGS84 (EPSG:4326) |
| englishName | country | English name of the selected country, according to GADM.org. |
| ISO3 | country | 3 letter ISO code for this |
| regionGID | region | Identifier of the region in GADM |
| countryEnglishName | region | English name of the country within which this region is. |
When using other selectors, the object create contains a subset of the location selector. For example, the countryRegion selector will only contain the country and region sections, and countryRegionCRS will contain all but the bbox section.
STAC assets
The stac_asset[] input type opens a STAC catalog browser. The user picks a catalog, a collection, then either a single item or all the tiles of the collection (on one date), and the asset to use. Several assets can be added to the selection, so the script receives a list, even when only one asset was chosen. A single selection has type stac_asset, for example to pass one asset from a script to the next.
- catalog: https://stac.geobon.org
collection: some-collection
date: "2020-01-01"
item: some-item
items_are_tiles: false
asset: data
href: https://example.com/some-item/data.tif
type: image/tiff; application=geotiff; profile=cloud-optimized
categorical: false
- catalog: https://planetarycomputer.microsoft.com/api/stac/v1
collection: some-other-collection
date: "2020-01-01"
item: null
items_are_tiles: true
asset: data
href: null
type: image/tiff; application=geotiff; profile=cloud-optimized
categorical: true| Key name | Description |
|---|---|
| catalog | URL of the STAC catalog. |
| collection | Identifier of the collection in that catalog. |
| date | Day in scope, as YYYY-MM-DD. The day of the chosen item, or the date chosen along with items_are_tiles. Can be null. |
| item | Identifier of the chosen item. Null when items_are_tiles is true. |
| items_are_tiles | When true, the script is expected to search the collection for all items (on date, if any) and mosaic their asset itself. |
| asset | Key of the asset within the item(s). |
| href | Direct link to the asset of the chosen item. Null when items_are_tiles is true. |
| type | Media type of the asset, as declared by the catalog. |
| categorical | True if the asset holds classes (e.g. land cover) rather than measurements. Useful to choose a resampling method (nearest neighbour vs. bilinear). |
Planetary Computer assets
Assets from Microsoft’s Planetary Computer must be signed before they can be read. Signing works without a key, but with tight rate limits; to raise them, set PLANETARY_COMPUTER_API_KEY in runner.env and restart the server. It is then available to scripts as an environment variable.
In Python, with the planetary-computer and pystac-client packages:
import os
import planetary_computer
from pystac_client import Client
if os.environ.get("PLANETARY_COMPUTER_API_KEY"):
planetary_computer.settings.set_subscription_key(os.environ["PLANETARY_COMPUTER_API_KEY"])
for selection in biab_inputs()["stac"]:
if selection["items_are_tiles"]:
catalog = Client.open(selection["catalog"], modifier=planetary_computer.sign_inplace)
items = catalog.search(collections=[selection["collection"]], datetime=selection["date"]).items()
hrefs = [item.assets[selection["asset"]].href for item in items] # to be mosaicked
else:
hrefs = [planetary_computer.sign(selection["href"])]In R, with the rstac package:
library(rstac)
key <- Sys.getenv("PLANETARY_COMPUTER_API_KEY")
sign_fn <- sign_planetary_computer(
headers = if (key != "") c("Ocp-Apim-Subscription-Key" = key)
)
selection <- input$stac[[1]]
found <- stac(selection$catalog) |>
stac_search(collections = selection$collection, ids = selection$item) |>
post_request() |>
items_sign(sign_fn)
href <- found$features[[1]]$assets[[selection$asset]]$href