geowatch.stac.stac_search_builder module

A tool to help build a STAC search json.

This does contain a command line interface, for legacy reasons, but is not intended to be a fully supported part of the GeoWATCH CLI.

SeeAlso:

../cli/stac_search.py

Accenture Notes:

class geowatch.stac.stac_search_builder.StacSearchBuilderConfig(*args, **kwargs)[source]

Bases: DataConfig

Helper to create STAC search json queries

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

default = {'api_key': <Value('env:SMART_STAC_API_KEY')>, 'cloud_cover': <Value(10)>, 'end_date': <Value(None)>, 'out_fpath': <Value(None)>, 'sensors': <Value('L2-S2')>, 'start_date': <Value(None)>}
geowatch.stac.stac_search_builder.print_provider_debug_information()[source]
geowatch.stac.stac_search_builder.check_processed_regions()[source]
geowatch.stac.stac_search_builder.build_search_json(start_date, end_date, sensors, api_key, cloud_cover)[source]

Construct the json that can be used for a stac search

Example

>>> from geowatch.stac.stac_search_builder import build_search_json
>>> start_date = '2017-01-01'
>>> end_date = '2020-01-01'
>>> sensors = 'L2-S2'
>>> api_key = None
>>> cloud_cover = 20
>>> search_json = build_search_json(start_date, end_date, sensors, api_key, cloud_cover)
>>> print('search_json = {}'.format(ub.urepr(search_json, nl=-1)))
search_json = {
    'stac_search': [
        {
            'collections': ['sentinel-2-l2a'],
            'endpoint': 'https://earth-search.aws.element84.com/v1',
            'query': {
                'eo:cloud_cover': {'lt': 20}
            },
            'headers': {},
            'start_date': '2017-01-01',
            'end_date': '2020-01-01'
        }
    ]
}
geowatch.stac.stac_search_builder.main(cmdline=1, **kwargs)[source]

Example

>>> # xdoctest: +SKIP
>>> # xdoctest: +REQUIRES(env:SLOW_DOCTEST)
>>> from geowatch.stac.stac_search_builder import main
>>> cmdline = 0
>>> kwargs = {
>>>     'start_date': '2017-01-01',
>>>     'end_date': '2020-01-01',
>>>     'sensors': 'L2-S2',
>>> }
>>> main(cmdline=cmdline, **kwargs)