The STAC extensionΒΆ
The OpenSeach for EO subsytem exposes also a STAC service, implemented as a OGC API Features conformant STAC API.
The landing page of the STAC API is linked from the GeoServer home page, and available at $HOST:$PORT/geoserver/ogc/stac
.
The API exposes the OpenSearch for EO contents, restructuring them as needed:
The collections table is mapped to STAC collections
The products table is mapped to STAC items
Given the differences in names and structures the STAC resources are created using templates, in particular:
The HTML representation is built using Freemarker templates
The GeoJSON representation is built using GeoJSON features templates
The default templates work against the default PostGIS database structure and can be customized to include new properties to follow eventual database modifications.
All built-in templates are copied over to the data directory for customization, and placed
in the $GEOSERER_DATA_DIR/templates/ogc/stac
folder:
collection.ftl
collection_include.ftl
collections.ftl
collections.json
item.ftl
item_include.ftl
items-content.ftl
items-empty.ftl
items-footer.ftl
items-header.ftl
items.json
landingPage.ftl
queryables-collection.ftl
queryables-common.ftl
queryables-global.ftl
search-content.ftl
search-empty.ftl
search-footer.ftl
search-header.ftl
Specifically for the JSON output:
$GEOSERER_DATA_DIR/templates/ogc/stac/collections.json is the collections template
$GEOSERER_DATA_DIR/templates/os-eo/items.json is the items template
The JSON templates in the case of STAC also drive database querying, the exposed STAC properties are back-mapped into database properties by interpreting the template. It is advised to keep property mapping as simple as possible to allow usage of native SQL queries and indexes while accessing the database through the STAC API.
For both items and collections, collection specific templates can also be provided, which would contain
directives and mappings unique to that collection.
A collection specific template can be placed in the same templates directory as above,
using the naming convention items-<COLLECTION_ID>.json
or collections-<COLLECTION_ID>.json
,
where <COLLECTION_ID>
is the collection identifier.
For example, if the collection is named SENTINEL2
:
The collections specific template for it is named
collections-SENTINEL2.json
The items template specific for it is named
items-SENTINEL2.json
More information about writing templates can be found in the templates guide.