API

Service Config

Please take a look into detailed information in Service Configuration.

Config module.

bdc_stac.config.BDC_STAC_USE_FOOTPRINT = 0

Flag to set if Item intersection should use Item.footprint. Defaults to 0, which means to use Item.bbox.

bdc_stac.config.SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:postgres@localhost:5432/bdc'

The database URI that should be used for the database connection. Defaults to 'postgresql://postgres:postgres@localhost:5432/bdc'.

bdc_stac.config.SQLALCHEMY_ECHO = False

Enables or disable debug output of statements to stderr. Defaults to False.

bdc_stac.config.SQLALCHEMY_ENGINE_OPTIONS = {'max_overflow': 10, 'pool_recycle': -1, 'pool_size': 5, 'poolclass': None}

Set SQLAlchemy engine options for pooling. You may set the following environment variables to customize pooling:

  • SQLALCHEMY_ENGINE_POOL_SIZE: The pool size. Defaults to 5.

  • SQLALCHEMY_ENGINE_MAX_OVERFLOW: Max pool overflow. Defaults to 10.

  • SQLALCHEMY_ENGINE_POOL_CLASS: The pool type for management. Defaults to 10.

  • SQLALCHEMY_ENGINE_POOL_RECYCLE: Define the given number of seconds to recycle pool. Defaults to -1, or no timeout.

bdc_stac.config.SQLALCHEMY_TRACK_MODIFICATIONS = False

Enable (True) or disable (False) signals before and after changes are committed to the database. Defaults to False.

bdc_stac.config.get_stac_extensions(*args)

Retrieve a list of STAC Extension URL.

Data Management

STAC data management.

This module describes the internal queries and utilities to retrieve STAC definitions collections items and artifacts from BDC-Catalog.

New in version 1.0: Integrate with BDC-Catalog v1.0+ and role system support.

exception bdc_stac.controller.InvalidBoundingBoxError(description)

Exception for malformed bounding box.

bdc_stac.controller.create_query_filter(query)

Create SQLAlchemy statement filter for Item metadata.

This function creates a SQLAlchemy filter mapping object to deal with Item properties. With this, the user may filter any property from STAC item properties context, according the spec.

Example

>>> # Create a statement to filter items which has the cloud cover less than 50 percent.
>>> create_query_filter({"eo:cloud_cover": {"lte": 50}})  
>>> # Create a statement to filter items which has the tile MGRS 23LLG
>>> create_query_filter({"bdc:tile": {"eq": "23LLG"}})  

Note

Queryable properties must be mapped in these functions.

Tip

You may face limitation when filtering for any non-indexed property. See PostgreSQL Indexes to improve any property you need.

bdc_stac.controller.format_timeline(timeline: Optional[List[Timeline]] = None)

Format the collection timeline values with Dateformat.

Parameters:

timeline (Optional[List[Timeline]]) – The collection timeline instance

Returns:

list of dates for the collection

Return type:

list

bdc_stac.controller.get_catalog(roles=None)

Retrieve all available collections.

Returns:

a list of available collections

Return type:

list

bdc_stac.controller.get_collection_crs(collection: Collection) str

Retrieve the CRS for a given collection.

By default, this method uses the grid reference system to retrieve collection crs. When no grid is set, tries to seek for property bdc:crs in Collection.properties.

Parameters:

collection (Collection) – The BDC Collection object

Returns:

CRS for the collection

Return type:

str

bdc_stac.controller.get_collection_eo(collection_id)

Get Collection Electro-Optical properties.

Note

This method uses LRU Cache to improve response time.

Parameters:

collection_id (str) – collection identifier

Return type:

eo_gsd, eo_bands (tuple(float, dict))

bdc_stac.controller.get_collection_items(collection_id=None, roles=None, item_id=None, bbox=None, datetime=None, ids=None, collections=None, intersects=None, page=1, limit=10, query=None, **kwargs) Pagination

Retrieve a list of collection items based on filters.

Parameters:
  • collection_id (str, optional) – Single Collection ID to include in the search for items. Only Items in one of the provided Collection will be searched, defaults to None

  • item_id (str, optional) – item identifier, defaults to None

  • bbox (list, optional) – bounding box for intersection [west, north, east, south], defaults to None

  • datetime (str, optional) – Single date+time, or a range (“/” seperator), formatted to RFC 3339, section 5.6. Use double dots “..” for open date ranges, defaults to None. If the start or end date of an image generated by a temporal composition intersects the given datetime or range it will be included in the result.

  • ids (list, optional) – Array of Item ids to return. All other filter parameters that further restrict the number of search results are ignored, defaults to None

  • collections (list, optional) – Array of Collection IDs to include in the search for items. Only Items in one of the provided Collections will be searched, defaults to None

  • intersects (dict, optional) – Searches items by performing intersection between their geometry and provided GeoJSON geometry. All GeoJSON geometry types must be supported., defaults to None

  • page (int, optional) – The page offset of results, defaults to 1

  • limit (int, optional) – The maximum number of results to return (page size), defaults to 10

  • query (dict, optional) – The STAC extra query internal properties

Returns:

list of collectio items

Return type:

list

bdc_stac.controller.get_collection_quicklook(collection_id)

Retrieve a list of bands used to create the quicklook for a given collection.

Parameters:

collection_id (str) – collection identifier

Returns:

list of bands

Return type:

list.

bdc_stac.controller.get_collections(collection_id=None, roles=None, assets_kwargs=None)

Retrieve information of all collections or one if an id is given.

Parameters:

collection_id (str) – collection identifier

Returns:

list of collections

Return type:

list

bdc_stac.controller.get_item_processors(item_id: int) dict

List the Processors used to compose the given Item.

Note

Follows the STAC Extension processing.

bdc_stac.controller.make_geojson(items, assets_kwargs='', exclude=None)

Generate a list of STAC Items from a list of collection items.

param items: collection items to be formated as GeoJSON Features type items: list param extension: The STAC extension for Item Context (sar/eo/label). type extension: str return: GeoJSON Features. rtype: list

bdc_stac.controller.parse_fields_parameter(fields: Optional[str] = None)

Parse the string parameter fields to include/exclude certain fields in response.

Follow the STAC API Fields Fragment.

bdc_stac.controller.resolve_base_file_root_url() str

Retrieve base URL used as STAC BASE URL ROOT for items from HTTP header.

Note

This method uses flask.request object to check for X-Script-Name in header. Make sure you are inside flask app context.

bdc_stac.controller.resolve_stac_url() str

Retrieve base URL used as STAC URL for items from HTTP header.

Note

This method uses flask.request object to check for X-Stac-Url in header. Make sure you are inside flask app context.