planetsca.download¶
This module contains functions for downloading Planet imagery via their API, planetsca models and sample data.
- download.build_payload(item_ids: List[str], aoi_coordinates: List[float], item_type: str, bundle_type: str) dict [source]¶
Helper function building payload for the Planet API
- Parameters:
item_ids (List[str]) – Item id that contains date and location information
aoi_coordinates (List[float]) – Area of interest coordinates
item_type (str) – Class of spacecraft and/or processing level of an item, defaults to PSScene. See https://developers.planet.com/docs/apis/data/items-assets/
bundle_type (str) – Groups of assets for an item and contain metadata, defaults to analytic_sr_udm2. See https://developers.planet.com/apis/orders/product-bundles-reference/#surface-reflectance-4b
- Returns:
payload – Dictionary containing all necessary information for the Planet API
- Return type:
dict
- download.download(api_key: str, order_url: str, out_dirpath: str, overwrite: bool = False) None [source]¶
Helper function for downloading the ordered data from Planet, makes a download request every 60 seconds until data is ready to download
- Parameters:
api_key (str) – Planet API key
order_url (str) – Order urls created from prepare_submit_orders()
out_dirpath (str) – Path to output directory
overwrite (bool) – Whether or not to overwrite existing files, defaults to False
- Return type:
None
- download.order(api_key: str, id_list: List[str], filter: dict, item_type: str = 'PSScene', bundle_type: str = 'analytic_sr_udm2') str [source]¶
Builds payload for Planet API and submits an order.
- Parameters:
api_key (str) – Planet API key
id_list (List[str]) – Item id that contains date and location information
filter (dict) – Dictionary containing data filter information
item_type (str) – Class of spacecraft and/or processing level of an item, defaults to PSScene. See https://developers.planet.com/docs/apis/data/items-assets/
bundle_type (str) – Groups of assets for an item and contain metadata, defaults to analytic_sr_udm2. See https://developers.planet.com/apis/orders/product-bundles-reference/#surface-reflectance-4b
- Returns:
order_url – URL from which to download image from Planet API
- Return type:
str
- download.order_now(api_key, payload)[source]¶
Helper function for ordering data from Planet
- Parameters:
api_key (str) – Planet API key
payload (dict) – Dictionary containing all necessary information for the Planet API
- Returns:
order_url – URL from which to download image from Planet API
- Return type:
str
- download.retrieve_dataset(filename: str, out_dirpath: str | None = '.') str [source]¶
Downloads sample datasets for PlanetSCA model from Hugging Face
- Parameters:
filename (str) – Filename of one of the PlanetSCA files on Hugging Face, see list of files here: https://huggingface.co/datasets/geo-smart/planetsca_datasets/tree/main
out_dirpath (Optional[str]) – Path to directory to save file
- Returns:
filepath – Path to local file
- Return type:
str
- download.retrieve_model(out_dirpath: str | None = None) RandomForestClassifier [source]¶
Downloads pre-trained PlanetSCA model from Hugging Face
- Parameters:
out_dirpath – Optional[str] Path to directory to save pre-trained model file
- Returns:
model – The trained PlanetSCA model
- Return type:
RandomForestClassifier
- download.retrieve_model_onnx(out_dirpath: str | None = None) ModelProto [source]¶
Downloads pre-trained PlanetSCA model from Hugging Face (ONNX format)
- Parameters:
out_dirpath – Optional[str] Path to directory to save pre-trained model file
- Returns:
model – The trained PlanetSCA model (ONNX format)
- Return type:
onnx.onnx_ml_pb2.ModelProto