Skip to content

Commit ee365ab

Browse files
Aggregation (#276)
**Related Issue(s):** - #245 **Description:** Adds support for The [Aggregation Extension](https://github.com/stac-api-extensions/aggregation) with an added dependency on the Filter Extension. This enables geo-aggregation of geometries and points, taking advantage of Opensearch and Elasticsearch's aggregation engines. Note that some of the geo-aggregation features will have to be left untested on the Elasticsearch backend implementation because they require a commercial license. TO DO: - ~~Need to support collection aggregations using the `<collection ID>/aggregate` route. Add support in the aggregate function in the core aggregations extension.~~ **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog
1 parent 5d52698 commit ee365ab

File tree

16 files changed

+65241
-679
lines changed

16 files changed

+65241
-679
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
## [Unreleased]
99

1010
### Added
11+
- Added an implementation of the Aggregation Extension. Enables spatial, frequency distribution, and datetime distribution aggregations. [#276](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/276)
1112
- Added support for route depndencies configuration through the STAC_FASTAPI_ROUTE_DEPENDENCIES environment variable, directly or via json file. Allows for fastapi's inbuilt OAuth2 flows to be used as dependencies. Custom dependencies can also be written, see Basic Auth for an example. [#251](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/251)
1213
- Added docker-compose.route_dependencies_file.yml that gives an example of OAuth2 workflow using keycloak as the identity provider. [#251](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/251)
1314
- Added docker-compose.route_dependencies_env.yml that gives an example using the STAC_FASTAPI_ROUTE_DEPENDENCIES environment variable. [#251](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/251)

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,109 @@ The modified Items with lowercase identifiers will now be visible to users acces
278278
## Auth
279279

280280
Authentication is an optional feature that can be enabled through `Route Dependencies` examples can be found and a more detailed explanation in [examples/auth](examples/auth).
281+
282+
283+
## Aggregation
284+
285+
Sfeos supports the STAC API [Aggregation Extension](https://github.com/stac-api-extensions/aggregation). This enables geospatial aggregation of points and geometries, as well as frequency distribution aggregation of any other property including dates. Aggregations can be defined at the root Catalog level (`/aggregations`) and at the Collection level (`/<collection_id>/aggregations`). The `/aggregate` route also fully supports base search and the STAC API [Filter Extension](https://github.com/stac-api-extensions/filter). Any query made with `/search` may also be executed with `/aggregate`, provided that the relevant aggregation fields are available,
286+
287+
288+
A field named `aggregations` should be added to the Collection object for the collection for which the aggregations are available, for example:
289+
290+
```json
291+
"aggregations": [
292+
{
293+
"name": "total_count",
294+
"data_type": "integer"
295+
},
296+
{
297+
"name": "datetime_max",
298+
"data_type": "datetime"
299+
},
300+
{
301+
"name": "datetime_min",
302+
"data_type": "datetime"
303+
},
304+
{
305+
"name": "datetime_frequency",
306+
"data_type": "frequency_distribution",
307+
"frequency_distribution_data_type": "datetime"
308+
},
309+
{
310+
"name": "sun_elevation_frequency",
311+
"data_type": "frequency_distribution",
312+
"frequency_distribution_data_type": "numeric"
313+
},
314+
{
315+
"name": "platform_frequency",
316+
"data_type": "frequency_distribution",
317+
"frequency_distribution_data_type": "string"
318+
},
319+
{
320+
"name": "sun_azimuth_frequency",
321+
"data_type": "frequency_distribution",
322+
"frequency_distribution_data_type": "numeric"
323+
},
324+
{
325+
"name": "off_nadir_frequency",
326+
"data_type": "frequency_distribution",
327+
"frequency_distribution_data_type": "numeric"
328+
},
329+
{
330+
"name": "cloud_cover_frequency",
331+
"data_type": "frequency_distribution",
332+
"frequency_distribution_data_type": "numeric"
333+
},
334+
{
335+
"name": "grid_code_frequency",
336+
"data_type": "frequency_distribution",
337+
"frequency_distribution_data_type": "string"
338+
},
339+
{
340+
"name": "centroid_geohash_grid_frequency",
341+
"data_type": "frequency_distribution",
342+
"frequency_distribution_data_type": "string"
343+
},
344+
{
345+
"name": "centroid_geohex_grid_frequency",
346+
"data_type": "frequency_distribution",
347+
"frequency_distribution_data_type": "string"
348+
},
349+
{
350+
"name": "centroid_geotile_grid_frequency",
351+
"data_type": "frequency_distribution",
352+
"frequency_distribution_data_type": "string"
353+
},
354+
{
355+
"name": "geometry_geohash_grid_frequency",
356+
"data_type": "frequency_distribution",
357+
"frequency_distribution_data_type": "numeric"
358+
},
359+
{
360+
"name": "geometry_geotile_grid_frequency",
361+
"data_type": "frequency_distribution",
362+
"frequency_distribution_data_type": "string"
363+
}
364+
]
365+
```
366+
367+
Available aggregations are:
368+
369+
- total_count (count of total items)
370+
- collection_frequency (Item `collection` field)
371+
- platform_frequency (Item.Properties.platform)
372+
- cloud_cover_frequency (Item.Properties.eo:cloud_cover)
373+
- datetime_frequency (Item.Properties.datetime, monthly interval)
374+
- datetime_min (earliest Item.Properties.datetime)
375+
- datetime_max (latest Item.Properties.datetime)
376+
- sun_elevation_frequency (Item.Properties.view:sun_elevation)
377+
- sun_azimuth_frequency (Item.Properties.view:sun_azimuth)
378+
- off_nadir_frequency (Item.Properties.view:off_nadir)
379+
- grid_code_frequency (Item.Properties.grid:code)
380+
- centroid_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.Properties.proj:centroid)
381+
- centroid_geohex_grid_frequency ([geohex grid](https://opensearch.org/docs/latest/aggregations/bucket/geohex-grid/) on Item.Properties.proj:centroid)
382+
- centroid_geotile_grid_frequency (geotile on Item.Properties.proj:centroid)
383+
- geometry_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.geometry)
384+
- geometry_geotile_grid_frequency ([geotile grid](https://opensearch.org/docs/latest/aggregations/bucket/geotile-grid/) on Item.geometry)
385+
386+
Support for additional fields and new aggregations can be added in the associated `database_logic.py` file.

0 commit comments

Comments
 (0)