Source-Code Docstrings#

Main Client#

class eodms_api_client.eodms.EodmsAPI(collection, username=None, password=None)[source]#

Entry-point for accessing the EODMS REST API

Inputs:
  • collection: The EODMS Collection to which queries and orders will be sent

  • username: EODMS account username, leave blank to use .netrc (if available)

  • password: EODMS account password, leave blank to use .netrc (if available)

query(**kwargs)[source]#

Submit a query to EODMS and save the results as a geodataframe in a class attribute

Inputs:
  • kwargs: Any number of keyword arguments that will be validated based on the EODMS collection being queried

Outputs:
  • self.results: A class attribute containing a geodataframe with the returned query results

order(record_ids, priority='Medium')[source]#

Submit an order to EODMS using record ID numbers retrieved from a search query

Inputs:
  • record_ids: list of record ID numbers to order

  • priority: Order submission priority. Must be one of [‘Low’, ‘Medium’, ‘High’, ‘Urgent’] Default: ‘Medium’

Outputs:
  • order_ids: list of EODMS ordering system ID numbers for later downloading

download(order_ids, output_location='.')[source]#

Appears that the endpoint has a hard limit of 100 results, so need to be fancy if more than 100 items are given for an orderId

order_ids: list of integer order numbers output_location: where the downloaded products will be saved to (will be created if doesn’t exist yet)

class eodms_api_client.eodms.EODMSHTMLFilter(*, convert_charrefs=True)[source]#

Custom HTML parser for EODMS API item status responses

Stolen from stackoverflow user FrBrGeorge: https://stackoverflow.com/a/55825140

EODMS Collection Parameter Validation#

eodms_api_client.params.validate_query_args(args, collection)[source]#

Try to validate as many keyword arguments as possible for the given EODMS collection

Inputs:
  • args: dictionary of keyword arguments provided by the user

  • collection: EODMS collection to validate arguments against

Outputs:
  • query: a properly-escaped query string ready to be sent to EODMS API

eodms_api_client.params.generate_meta_keys(collection)[source]#

For the given collection, return the various keys that will be used to pull image metadata from EODMS

eodms_api_client.params.available_query_args(collection)[source]#

For a given EODMS collection, produce a dictionary of available query parameters for use in EodmsAPI.query calls

Geographic Functions#

eodms_api_client.geo.transform_metadata_geometry(meta_geom, target_crs=None)[source]#

Transform a given image footprint geometry from WGS84 to the desired crs

EODMS always returns geometries in WGS84, so we provide the option to transform into something more useful through the use of a CLI flag (–t_srs)

Inputs:
  • meta_geom: the footprint geometry as a shapely.geometry object

  • target_crs: either a pyproj.CRS or properly-formatted string for the desired projection

Outputs:
  • if target_crs is not supplied, simply return the passed geometry

  • if target_crs is supplied, return the transformed geometry

eodms_api_client.geo.metadata_to_gdf(metadata, collection, target_crs=None)[source]#

Instead of a jumbled JSON-looking dictionary, create a geopandas.GeoDataFrame from the EODMS search query response

Inputs:
  • metadata: dictionary of EODMS search query and image metadata response

  • collection: string of EODMS Collection ID - used for column name standardization

  • target_crs: pyproj.CRS instance or properly-formatted string for the desired projection

Outputs:
  • df: geopandas.GeoDataFrame containing <metadata> projected to <target_crs>

eodms_api_client.geo.load_search_aoi(geofile)[source]#

Given a file, attempt to parse it as a set of vector features to be sent as part of a request to the EODMS REST API. If the features are not already in WGS84, they are transformed by this function.

Inputs:
  • geofile: A file containing vector data (SHP, GEOJSON, GPKG, etc.)

Outputs:
  • wkt: The Well-Known Text representation of the features within <geofile>

Authentication Functions#

eodms_api_client.auth.create_session(username=None, password=None)[source]#

Create a persistent session object for the EODMS REST API using the given username and password. If neither is provided, attempt to use the .netrc file and fallback to console entry as a last-resort

Inputs:
  • username: EODMS username

  • password: EODMS password

Outputs:
  • session: requests.Session object for the EODMS REST API