Exemplo n.º 1
0
def download(dataset, node, entityids, product='STANDARD', api_key=None):
    """
    Though USGS supports multiple products in a single request, there's
    ambiguity in the returned list. This wrapper only allows a single
    product per request.

    Additionally, the response has no indiction which URL is associated
    with which scene/entity id. The URL can be parsed, but the structure
    varies depending on the product.
    """

    api_key = _get_api_key(api_key)

    url = '{}/download'.format(USGS_API)
    payload = {
        "jsonRequest":
        payloads.download(dataset, node, entityids, [product], api_key=api_key)
    }

    r = requests.post(url, payload)
    response = r.json()

    _check_for_usgs_error(response)

    return response
Exemplo n.º 2
0
    def test_download(self):

        expected = """{"node": "EE", "products": ["STANDARD"], "datasetName": "LANDSAT_8_C1", "apiKey": "USERS API KEY", "entityIds": ["LC80130292014100LGN00"]}"""

        payload = payloads.download("LANDSAT_8_C1",
                                    "EE", ["LC80130292014100LGN00"],
                                    ["STANDARD"],
                                    api_key="USERS API KEY")
        assert compare_json(payload, expected)
Exemplo n.º 3
0
Arquivo: api.py Projeto: mapbox/usgs
def download(dataset, node, entityids, product='STANDARD', api_key=None):
    """
    Though USGS supports multiple products in a single request, there's
    ambiguity in the returned list. This wrapper only allows a single
    product per request.

    Additionally, the response has no indiction which URL is associated
    with which scene/entity id. The URL can be parsed, but the structure
    varies depending on the product.
    """

    api_key = _get_api_key(api_key)

    url = '{}/download'.format(USGS_API)
    payload = {
        "jsonRequest": payloads.download(dataset, node, entityids, [product], api_key=api_key)
    }

    r = requests.post(url, payload)
    response = r.json()

    _check_for_usgs_error(response)

    return response
Exemplo n.º 4
0
    def test_download(self):

        expected = """{"node": "EE", "products": ["STANDARD"], "datasetName": "LANDSAT_8_C1", "apiKey": "USERS API KEY", "entityIds": ["LC80130292014100LGN00"]}"""

        payload = payloads.download("LANDSAT_8_C1", "EE", ["LC80130292014100LGN00"], ["STANDARD"], api_key="USERS API KEY")
        assert compare_json(payload, expected)