STAC

Documentation for STAC, a Julia client implementation of the SpatioTemporal Asset Catalogs.

STAC catalog

STAC.CatalogType
cat = STAC.Catalog(url)

Open a SpatioTemporal Asset Catalog (STAC) using the provided url. The url should point to a JSON object conforming to the STAC specification.

cat behaves as a julia dictionary with all STAC subcatalogs. cat.items is a dictionary with all STAC items.

using STAC
url = "https://raw.githubusercontent.com/sat-utils/sat-stac/master/test/catalog/catalog.json"
cat = STAC.Catalog(url)
subcat = cat["stac-catalog-eo"]
subcat1 = subcat["landsat-8-l1"]
@show subcat1

item = subcat1.items["LC08_L1TP_152038_20200611_20200611_01_RT"]
@show href(item.assets["B4"])
source
Base.keysMethod
child_ids = keys(cat::Catalog)
subcat = cat[child_id]

Returns all subcatalog identifiers of the STAC catalog cat.

url = "https://raw.githubusercontent.com/sat-utils/sat-stac/master/test/catalog/catalog.json"
cat = STAC.Catalog(url);
keys(cat)
source
Base.getindexMethod
subcat = getindex(cat::Catalog,child_id::AbstractString)
subcat = cat[child_id]

Returns the subcatalogs with the identifier child_id

url = "https://raw.githubusercontent.com/sat-utils/sat-stac/master/test/catalog/catalog.json"
cat = STAC.Catalog(url);
subcat = cat["stac-catalog-eo"]
source
STAC.eachcatalogMethod
cats = eachcatalog(catalog::Catalog)

Returns resursively all subcatalogs in catalog. This can take a long time for deeply nested catalogs.

url = "https://raw.githubusercontent.com/sat-utils/sat-stac/master/test/catalog/catalog.json"

cat = STAC.Catalog(url)
for c in eachcatalog(cat)
    @show id(c)
end
source
STAC.eachitemMethod
cats = eachitem(catalog::Catalog)

Returns resursively all items in catalog. This can take a long time for deeply nested catalogs.

url = "https://raw.githubusercontent.com/sat-utils/sat-stac/master/test/catalog/catalog.json"

cat = STAC.Catalog(url)
for c in eachitem(cat)
    @show id(c)
end
source
STAC.searchFunction
search(cat::Catalog, collections, lon_range, lat_range, datetime;
       limit = 200,
       filter = nothing,
       query = nothing,
)

Search items in a STAC.Catalog cat belong to the collections within the longitude range lon_range (start and end longitude), latitude range lat_range, and time range (start and end DateTime).

The optional filter parameter allows to filter the resuts using CQL2 (see example below). STACQL is also supported via the optional query parameter. It is recommended to use CQL2 instead of STACQL. This filter and query are experimental and currently only part of the STAC as a "candiate" or "pilot".

The function search returns an julia Channel with the search results over which one can only iterate once. If the results should be saved use search_results = collect(search(cat,...)).

Example:

using STAC, Dates
collections = ["landsat-8-c2-l2"]
time_range = (DateTime(2018,01,01), DateTime(2018,01,02))
lon_range = (2.51357303225, 6.15665815596)
lat_range = (49.5294835476, 51.4750237087)

catalog = STAC.Catalog("https://planetarycomputer.microsoft.com/api/stac/v1")

search_results = collect(search(catalog, collections, lon_range, lat_range, time_range))

Example with additional CQL2 filter

filter = Dict(
   "op" => "<=",
   "args" => [Dict("property" => "eo:cloud_cover"), 61]
)

search_results = collect(
        search(cat, collections,
               lon_range, lat_range, time_range,
               filter = filter,
))

Currently only POST search requests are supported.

source
STAC.typeMethod
data = type(cat::Catalog; default = nothing)

Get the type of a STAC catalog (or default if it is not specified).

source
STAC.stac_versionMethod
data = stac_version(cat::Catalog; default = nothing)

Get the stac version of a STAC catalog (or default if it is not specified).

source
STAC.stac_extensionsMethod
data = stac_extensions(cat::Catalog; default = nothing)

Get the stac extensions of a STAC catalog (or default if it is not specified).

source
STAC.idMethod
data = id(cat::Catalog; default = nothing)

Get the identifier of a STAC catalog (or default if it is not specified).

source
STAC.titleMethod
data = title(cat::Catalog; default = nothing)

Get the title of a STAC catalog (or default if it is not specified).

source
STAC.descriptionMethod
data = description(cat::Catalog; default = nothing)

Get the description of a STAC catalog (or default if it is not specified).

source
STAC.keywordsMethod
data = keywords(cat::Catalog; default = nothing)

Get the keywords of a STAC catalog (or default if it is not specified).

source
STAC.licenseMethod
data = license(cat::Catalog; default = nothing)

Get the license of a STAC catalog (or default if it is not specified).

source
STAC.providersMethod
data = providers(cat::Catalog; default = nothing)

Get the providers of a STAC catalog (or default if it is not specified).

source
STAC.extentMethod
data = extent(cat::Catalog; default = nothing)

Get the extent of a STAC catalog (or default if it is not specified).

source
STAC.summariesMethod
data = summaries(cat::Catalog; default = nothing)

Get the summaries of a STAC catalog (or default if it is not specified).

source

STAC item

STAC.idMethod
 data = id(item)

Get the identifier of STAC item.

source
STAC.bboxMethod
 data = bbox(item)

Get the bounding box of STAC item.

source
Dates.DateTimeMethod
dt = DateTime(item)

Get the date time of STAC item as a Dates.DateTime (or nothing if this properties is not specified).

source

STAC asset

STAC.hrefMethod
 data = href(asset; default = nothing)

Get the URI of a STAC asset (or default if it is not specified).

source
STAC.titleMethod
 data = title(asset; default = nothing)

Get the title of a STAC asset (or default if it is not specified).

source
STAC.descriptionMethod
 data = description(asset; default = nothing)

Get the description of a STAC asset (or default if it is not specified).

source
STAC.typeMethod
 data = type(asset; default = nothing)

Get the type of a STAC asset (or default if it is not specified).

source

Cache

STAC.set_cache_max_sizeFunction
STAC.set_cache_max_size(cache_max_size::Integer)

Set the maximum number of URLs saved in cache (permanentaly). The default is 1000.

source

Customize

The color scheme used of the STAC client can be customized by the following functions: