Client library for interfacing with USGS datasets

Related tags

Geolocation usgs
Overview

USGS API

USGS is a python module for interfacing with the US Geological Survey's API. It provides submodules to interact with various endpoints, and command line utilities, helpful for building out large pipelines.

Documentation is available at:

http://kapadia.github.io/usgs/

ChangeLog

0.3.0 Update the USGS Machine to Machine API from 1.4 to 1.5

0.2.6 [email protected]
Remove dependency on pyproj and shapely and use great circle computation to expand a point search to a box
Comments
  • ConnectionError

    ConnectionError

    Trying to use the command line tool to search and getting connection errors each time:

        usgs search LANDSAT_8 --node EE --start-date 20150401 --end-date 20150501
    
        Traceback (most recent call last):
      File "/usr/local/bin/usgs", line 9, in <module>
        load_entry_point('usgs==0.1.5', 'console_scripts', 'usgs')()
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 644, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/usgs/scripts/cli.py", line 166, in search
        data = api.search(dataset, node, lat=latitude, lng=longitude, distance=distance, ll=lower_left, ur=upper_right, start_date=start_date, end_date=end_date, where=where, extended=extended, api_key=api_key)
      File "/usr/local/lib/python2.7/site-packages/usgs/api.py", line 266, in search
        r = requests.post(USGS_API, xml)
      File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 109, in post
        return request('post', url, data=data, json=json, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 50, in request
        response = session.request(method=method, url=url, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
        r = adapter.send(request, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
        raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
    

    Ran pip install usgs --upgrade right beforehand so should have the most recent deps, OSX 10.9.2

    opened by drewbo 12
  • Inventory service access

    Inventory service access

    Was looking to poke around with this, but am receiving the following:

      File "/usr/local/bin/usgs", line 9, in <module>
        load_entry_point('usgs==0.1.1.dev0', 'console_scripts', 'usgs')()
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 644, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/usgs/scripts/cli.py", line 65, in login
        api_key = api.login(username, password)
      File "/usr/local/lib/python2.7/site-packages/usgs/api.py", line 149, in login
        raise Exception(r.text)
    Exception: <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>AUTH_ERROR</faultcode><faultstring>Authentication Failed: User does not have Inventory Service access.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
    

    The credentials I'm using are the same that I use for Earth Explorer, which work fine. Do I need to do anything fancy to get Inventory Service access?

    Thanks!

    opened by jqtrde 7
  • Credentials not working yet

    Credentials not working yet

    Folks from USGS wrote saying that our shared account credentials are ready. When logging in:

    usgs login [username] [password]
    

    we still get an authentication failure. I'll first check that the request made by this module is coherent; if not, I'll email USGS again about the issue.

    /cc @celoyd @warmerdam

    opened by kapadia 7
  • USGSError: AUTH_UNAUTHORIZED

    USGSError: AUTH_UNAUTHORIZED

    Hi,

    I am getting an error when using the download method of the api:

    usgs.USGSError: AUTH_UNAUTHORIZED: Forbidden - Approved role required for access to 'download' method.
    

    Could there be something wrong with my EarthExplorer account?

    Many thanks!

    opened by tvoirand 5
  • Add dataset-download-options endpoint

    Add dataset-download-options endpoint

    This PR would close #64 by adding an api.dataset_download_options function to access the dataset-download-options endpoint.

    It also adds the necessary payload and unit tests.

    Let me know if you see and changes needed, @kapadia :)

    P.S. I didn't implement the sceneFilter parameter that the endpoint accepts because it would complicate the implementation and, to be honest, I don't understand the point of it. Seems to me that if someone wants to know product availability for specific filters they'll be using those filters to find scenes and checking products for those scenes with the download-options endpoint. But maybe there's an application I'm not thinking of. Let me know if you think that's important and I can add it.

    opened by aazuspan 3
  • download_request fails with ConnectionError

    download_request fails with ConnectionError

    Hello, I am trying to download a product but download_request() hangs then fails:

    >>> import usgs
    >>> from usgs import api
    >>> usgs.__version__
    '0.3.0'
    >>> api.login("login", "password,", save=True)
    >>> download_options = api.download_options('LANDSAT_8_C1', 'LC80612142021055LGN00')
    >>> product_ids = [ p["id"] for p in download_options["data"] if p["downloadSystem"] == "dds" ]
    >>> download_request = api.download_request('LANDSAT_8_C1', 'LC80612142021055LGN00', product_ids[0])
    
    Traceback (most recent call last):
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
        httplib_response = self._make_request(
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
        six.raise_from(e, None)
      File "<string>", line 3, in raise_from
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
        httplib_response = conn.getresponse()
      File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
        response.begin()
      File "/usr/lib/python3.8/http/client.py", line 307, in begin
        version, status, reason = self._read_status()
      File "/usr/lib/python3.8/http/client.py", line 276, in _read_status
        raise RemoteDisconnected("Remote end closed connection without"
    http.client.RemoteDisconnected: Remote end closed connection without response
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
        resp = conn.urlopen(
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
        retries = retries.increment(
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/util/retry.py", line 410, in increment
        raise six.reraise(type(error), error, _stacktrace)
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/packages/six.py", line 734, in reraise
        raise value.with_traceback(tb)
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
        httplib_response = self._make_request(
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
        six.raise_from(e, None)
      File "<string>", line 3, in raise_from
      File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
        httplib_response = conn.getresponse()
      File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
        response.begin()
      File "/usr/lib/python3.8/http/client.py", line 307, in begin
        version, status, reason = self._read_status()
      File "/usr/lib/python3.8/http/client.py", line 276, in _read_status
        raise RemoteDisconnected("Remote end closed connection without"
    urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
    

    Maybe there is an issue on USGS M2M API side ?

    opened by sbrunato 3
  • Demise of the USGS/EROS SOAP API

    Demise of the USGS/EROS SOAP API

    I just received the message copied below. Is there any plan to support the new API or will this library stop working after May 15?

    Dear Machine-To-Machine EarthExplorer User.

    USGS/EROS will retire support for the SOAP API on May 1, 2017.

    The JSON / REST API is the primary Machine-To-Machine protocol and after May 1st it will be the only API supported for bulk data downloads.

    https://earthexplorer.usgs.gov/inventory/documentation

    A two week grace period will be in effect to provide more time if you need it to make the transition from SOAP to JSON.

    However, all SOAP calls made after May 15 will be bounced and only JSON calls will be honored for data downloads.

    Thank you for your cooperation in this matter,

    Tim Smith Data Management & Information Task Lead Stinger Ghaffarian Technologies (SGT, Inc.) Contractor to the U.S. Geological Survey (USGS) Earth Resources Observation and Science (EROS) Center 47914 252nd Street Sioux Falls, SD 57198

    opened by ghost 3
  • Error Running Sample code from docs

    Error Running Sample code from docs

    I was just trying to use the sample code for the api in the docs and I get this error.

    usgs.USGSError: SEARCH_ERROR: Could not complete data field request

    opened by dkowalsky7 3
  • tests with mock + py3 fixes + api_key for download

    tests with mock + py3 fixes + api_key for download

    I've made a few changes so I can use the library in two of my projects:

    The changes are:

    • used a simpler function for xml tree compare tests instead of using Django
    • done some linting and Python 3 fixes
    • added apy_key as an argument to two of the functions
    • added mocks for a few tests
    • save api_key to ~/.usgs instead of /tmp/usgs

    Feel free to merge if they are helpful. Thanks.

    Also, the few tests that are not skipped pass on travis if you turn it on. Here are the results: https://travis-ci.org/developmentseed/usgs

    opened by scisco 3
  • 'Where' parameter documentation

    'Where' parameter documentation

    Not sure how to search using additional filtering parameters (both syntax and which parameters can be queried on):

    from usgs import api
    
    where = {'WRS Path': '043'}
    api.search('LANDSAT_8', 'EE',  where=where, start_date='2015-04-01', end_date='2015-05-01', max_results=10, extended=True)
    
    usgs.USGSError: Could not complete search request: Failed to append additional criteria to query.
    
    opened by drewbo 3
  • Collab with Planet Labs

    Collab with Planet Labs

    After meeting with Planet - USGS - Amazon just before the holidays (https://github.com/mapbox/satellite/issues/916), we promised to share the code we use to interface with the USGS API. Much of the functionality has been moved from airphoto/usgs into this repo.

    Do we have a GitHub group to collaborate with Planet?

    /cc @celoyd @yhahn

    opened by kapadia 3
  • How to download Landsat-8 C2-L2 files using the USGS module

    How to download Landsat-8 C2-L2 files using the USGS module

    Please forgive any posting conventions, this is my first time posting an issue.

    the documentation found in (http://kapadia.github.io/usgs/reference/api.html) suggests that there is a method called usgs.api.download which can be used to download Landsat-8 datasets, yet I can't seem to find it, the only one available usgs.api.download_options which does not initiate any download actions, it returns a response.

    Here is my code so far, it works but does not initiate any downloading:

    from usgs import api
    
    # login
    response = api.login(username, password)
    api_key = response["data"]
    landsat8_dataset = 'landsat_ot_c2_l2'
    
    landsat8_scene_id = 'LC81970362017213LGN00'
    productid='LC08_L2SP_197036_20170801_20200903_02_T1'
    node='EE'
    
    api.download_options(landsat8_dataset, landsat8_scene_id,api_key=api_key)
    
    opened by WALEE1789 0
  • Should the

    Should the "save" argument to login be enabled by default?

    The behavior of the M2M API recently changed where if you try to login using an invalid or expired token, there will be an error message. The login will by default supply old tokens to the request with the .usgs file saved in the home folder (when the save argument during login = true). This will result in an error being raised to the end user saying that their authentication has been revoked and with the new change may be more confusing than it's worth if the behavior of the M2M api remains this way.

    opened by coreyryanhanson 0
  • Missing Vendor Product and Tile IDs in the updated USGS api

    Missing Vendor Product and Tile IDs in the updated USGS api

    Also, I did try to download sentinel-2 imagery using USGS API. Previously I was getting Vendor Product ID and Vendor Tile ID. since the update of the new 0.3.0 version of the USGS API, I cannot find both the "Vendor Product ID" and "Vendor Tile ID," Please suggest how I can access this?

    {'browse': [{'id': '5e83a42ca2265449', 'browseRotationEnabled': None, 'browseName': 'Standard Browse', 'browsePath': 'https://ims.cr.usgs.gov/browse/s2/s2a/2016/12/21/L1C_T14SPH_A007831_20161221T172206.jpg', 'overlayPath': 'https://ims.cr.usgs.gov/wms.py?service=WMS&request=GetMap&map=sentinel_2a&layers=L1C_T14SPH_A007831_20161221T172206', 'overlayType': 'ims_wms', 'thumbnailPath': 'https://ims.cr.usgs.gov/thumbnail/s2/s2a/2016/12/21/L1C_T14SPH_A007831_20161221T172206.jpg'}], 'cloudCover': '99.51860', 'entityId': '853993', 'displayId': 'L1C_T14SPH_A007831_20161221T172206', 'orderingId': None, 'metadata': [], 'hasCustomizedMetadata': None, 'options': {'bulk': True, 'download': True, 'order': True, 'secondary': False}, 'selected': {'bulk': False, 'compare': False, 'order': False}, 'spatialBounds': {'type': 'Polygon', 'coordinates': [[[-97.8632824, 37.8353021], [-97.8632824, 38.8433146], [-96.5832678, 38.8433146], [-96.5832678, 37.8353021], [-97.8632824, 37.8353021]]]}, 'spatialCoverage': {'type': 'Polygon', 'coordinates': [[[-97.8632824, 37.853955], [-96.6159, 37.8353021], [-96.5832678, 38.8239923], [-97.8477095, 38.8433146], [-97.8632824, 37.853955]]]}, 'temporalCoverage': {'endDate': '2016-12-21 00:00:00-06', 'startDate': '2016-12-21 00:00:00-06'}, 'publishDate': '2017-01-07 06:38:42-06'}

    opened by abhiramp1 1
  • usgs uses minimum bounding rectangle now for spatial filter

    usgs uses minimum bounding rectangle now for spatial filter

    https://earthexplorer.usgs.gov/inventory/documentation/test?version=1.3.0 used ll and ur coordinates but the later api versions use the MBR. I think this might be what is causing my Remote Disconnected errors.

    This payload would need to be updated in the search function, I'll see if I can fix this and submit a PR if PRs are being accepted.

    opened by rbavery 7
Rasterio reads and writes geospatial raster datasets

Rasterio Rasterio reads and writes geospatial raster data. Geographic information systems use GeoTIFF and other formats to organize and store gridded,

Mapbox 1.9k Jan 7, 2023
Summary statistics of geospatial raster datasets based on vector geometries.

rasterstats rasterstats is a Python module for summarizing geospatial raster datasets based on vector geometries. It includes functions for zonal stat

Matthew Perry 437 Dec 23, 2022
User friendly Rasterio plugin to read raster datasets.

rio-tiler User friendly Rasterio plugin to read raster datasets. Documentation: https://cogeotiff.github.io/rio-tiler/ Source Code: https://github.com

null 372 Dec 23, 2022
A public data repository for datasets created from TransLink GTFS data.

TransLink Spatial Data What: TransLink is the statutory public transit authority for the Metro Vancouver region. This GitHub repository is a collectio

Henry Tang 3 Jan 14, 2022
A NASA MEaSUREs project to provide automated, low latency, global glacier flow and elevation change datasets

Notebooks A NASA MEaSUREs project to provide automated, low latency, global glacier flow and elevation change datasets This repository provides tools

NASA Jet Propulsion Laboratory 27 Oct 25, 2022
List of Land Cover datasets in the GEE Catalog

List of Land Cover datasets in the GEE Catalog A list of all the Land Cover (or discrete) datasets in Google Earth Engine. Values, Colors and Descript

David Montero Loaiza 5 Aug 24, 2022
Helping data scientists better understand their datasets and models in text classification. With love from ServiceNow.

Azimuth, an open-source dataset and error analysis tool for text classification, with love from ServiceNow. Overview Azimuth is an open source applica

ServiceNow 145 Dec 23, 2022
Asynchronous Client for the worlds fastest in-memory geo-database Tile38

This is an asynchonous Python client for Tile38 that allows for fast and easy interaction with the worlds fastest in-memory geodatabase Tile38.

Ben 53 Dec 29, 2022
Geocoding library for Python.

geopy geopy is a Python client for several popular geocoding web services. geopy makes it easy for Python developers to locate the coordinates of addr

geopy 3.8k Dec 30, 2022
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 832 Dec 31, 2022
PySAL: Python Spatial Analysis Library Meta-Package

Python Spatial Analysis Library PySAL, the Python spatial analysis library, is an open source cross-platform library for geospatial data science with

Python Spatial Analysis Library 1.1k Dec 18, 2022
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 832 Dec 31, 2022
peartree: A library for converting transit data into a directed graph for sketch network analysis.

peartree ?? ?? peartree is a library for converting GTFS feed schedules into a representative directed network graph. The tool uses Partridge to conve

Kuan Butts 183 Dec 29, 2022
Python library to decrypt Airtag reports, as well as a InfluxDB/Grafana self-hosted dashboard example

Openhaystack-python This python daemon will allow you to gather your Openhaystack-based airtag reports and display them on a Grafana dashboard. You ca

Bezmenov Denys 19 Jan 3, 2023
prettymaps - A minimal Python library to draw customized maps from OpenStreetMap data.

A small set of Python functions to draw pretty maps from OpenStreetMap data. Based on osmnx, matplotlib and shapely libraries.

Marcelo de Oliveira Rosa Prates 9k Jan 8, 2023
Hapi is a Python library for building Conceptual Distributed Model using HBV96 lumped model & Muskingum routing method

Current build status All platforms: Current release info Name Downloads Version Platforms Hapi - Hydrological library for Python Hapi is an open-sourc

Mostafa Farrag 15 Dec 26, 2022
A library to access OpenStreetMap related services

OSMPythonTools The python package OSMPythonTools provides easy access to OpenStreetMap (OSM) related services, among them an Overpass endpoint, Nomina

Franz-Benjamin Mocnik 342 Dec 31, 2022
Python library to visualize circular plasmid maps

Plasmidviewer Plasmidviewer is a Python library to visualize plasmid maps from GenBank. This library provides only the function to visualize circular

Mori Hideto 9 Dec 4, 2022
Fully Automated YouTube Channel ▶️with Added Extra Features.

Fully Automated Youtube Channel ▒█▀▀█ █▀▀█ ▀▀█▀▀ ▀▀█▀▀ █░░█ █▀▀▄ █▀▀ █▀▀█ ▒█▀▀▄ █░░█ ░░█░░ ░▒█░░ █░░█ █▀▀▄ █▀▀ █▄▄▀ ▒█▄▄█ ▀▀▀▀ ░░▀░░ ░▒█░░ ░▀▀▀ ▀▀▀░

sam-sepiol 249 Jan 2, 2023
Automated download of LANDSAT data from USGS website

LANDSAT-Download It seems USGS has changed the structure of its data, and so far, I have not been able to find the direct links to the products? Help

Olivier Hagolle 197 Dec 30, 2022