Skip to main content

An object oriented method for working with the USGS EE machine-2-machine API v1.5

Project description

USGS Python API

An object oriented wrapper around the USGS Earth Explorer JSON API (v1.5.x). The primary objective of this API is to provide a convenient method of requesting and downloading scenes from EE datasets, including robust metadata where available.

API Documentation

https://cast.git-pages.uark.edu/transmap-hub/usgs/usgs/

Prerequisites

Installation and Setup

Three methods for using your username and password

  1. Using a .env file
EE_USER="user_name"
EE_PASS="user_pass"
  1. Set your environment variables manually
$ export EE_USER="user_name"
$ export EE_PASS="user_pass"
  1. During each execution you will be prompted for your user:pass if one of the above two options are not set
  2. Hard code within script (not recommended) - see below

Installation (development)

$ pipenv install
$ pipenv run python ./example.py

Basic API structure

To query a specific item, like a dataset or a scene, you need to construct a Query object from that namespace (dataset.Query, scene.Query) and pass that to the Api with either a fetch or fetchone. This will return a Model or List[Model] of that type (dataset.Model, scene.Model)

Initialize the API

from usgs_api import Api
api = Api.login()
### If you want to directly type your user:password you can use
api = Api(username="user_name", password="password")

Query a dataset by name

dataset = api.dataset(datasetName="corona2")

Start a scene cursor with a list of scenes

scene_cursor = dataset.scenes()

Collect only available scenes to queue for download

downloadable = scene_cursor.downloadable

Iterate the cursor to collect more scenes

downloadable += scene_cursor.next().downloadable

Enqueue the scenes for download from the Api

api.download(scenes)

Start the download and automate the extraction

api.start_download(extract=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usgs-m2m-api-0.2.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

usgs_m2m_api-0.2.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file usgs-m2m-api-0.2.0.tar.gz.

File metadata

  • Download URL: usgs-m2m-api-0.2.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/3.10.0-1160.6.1.el7.x86_64

File hashes

Hashes for usgs-m2m-api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0ffa97bc7a00fd68a889063333b6467b838962a643401f4f77dfbba114c50e0b
MD5 655f3d11922a7c7c082480bd362e9591
BLAKE2b-256 97b6f8fb5fa772bc74f83a35504922da8e4a6e9211f4ea394059cbd82ab58ebc

See more details on using hashes here.

File details

Details for the file usgs_m2m_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: usgs_m2m_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/3.10.0-1160.6.1.el7.x86_64

File hashes

Hashes for usgs_m2m_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 377a8f345dcae49f02f03ba3b6fee2ffbc4659203013e9679943c80d4a48eacb
MD5 b57ce76e09b3b55413951eab73fbc762
BLAKE2b-256 8c88d26963c44be45daf540d7c64cb511e40742a43467b9ad7360e95c513111b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page