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:
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:
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:
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