Planetary Computer (PC) Class
- class terragon.microsoft_planetary_computer.PC(credentials=None, base_url='https://planetarycomputer.microsoft.com/api/stac/v1/')
Bases:
BaseThe class for Microsoft Planetary Computer downloads. The package odc-stac will be used to download the images.
- Parameters:
Base – Base class defining the interface and some common methods
credentials (
dict) – credentials to authenticate, expected format: {‘api_key’: <key>}, defaults to Nonebase_url (
str) – the URL for the STAC catalog, defaults to “https://planetarycomputer.microsoft.com/api/stac/v1/”
- download(items)
Download the items from the Planetary Computer and return a xarray.Dataset or download the files and return a list of filenames. If create_minicube is set to True, a xarray.Dataset will be returned, otherwise a list of filenames will be returned.
- Parameters:
items – items to download
- Return type:
typing.Union[xarray.core.dataset.Dataset,list]- Returns:
xarray.Dataset or list of filenames
- retrieve_collections(query={}, fields=[])
Search the collections provided by Microsoft Planetary Computer.
- Parameters:
query (
dict) – query to filter the collections for in style ‘{<key>:<regex>}’, defaults to {}fields (
list[str]) – list of fields to include in the response, defaults to []
- Return type:
list- Returns:
a list of dictionaries with collection metadata
- search(odc_stac_kwargs={}, *args, **kwargs)
Search for items in the Planetary Computer collections, return the items and their meta data, and store the parameters in the class in order to access them later in the download function. For a description of the args/kwargs parameters see the Base class function.
- Parameters:
odc_stac_kwargs – additional parameters for the odc.stac.load function, defaults to {}
args/kwargs – Parameters which are handled by the parent class, these parameters are the same for all data providers. See the ‘Base’ class for more information.
- Raises:
ValueError – when no items are found or parameters are in the wrong format
- Returns:
a list of items