Esempio n. 1
0
def download_sentinel_data(item, bands):
    # get paths w.r.t. id
    paths = file_paths_wrt_id(item._data["id"])
    # get meta info on path, to be used by boto3
    info_response = requests.get(item.assets["info"]["href"])
    info_response_json = json.loads(info_response.text)
    # save bands generically
    for band in bands:
        # pass band id in metadata
        info_response_json["band_id"] = band
        band_filename = paths["b%s" % band]
        if not data_file_exists(band_filename):
            save_to_file(
                item.assets["B0{}".format(band)]["href"],
                band_filename,
                item._data["id"],
                "✗ required data doesn't exist, downloading %s %s"
                % (band_tag_map["b" + str(band)], "band"),
                meta=info_response_json,
            )
        else:
            rprint(
                "[green] ✓ ",
                "required data exists for {} band".format(
                    band_tag_map["b" + str(band)]
                ),
            )
    return item._data["id"]
Esempio n. 2
0
def preview_satellite_image(item):
    paths = file_paths_wrt_id(item._data["id"])
    # download image and save it in directory
    if not data_file_exists(paths["preview"]):
        save_to_file(
            item.assets["thumbnail"]["href"],
            paths["preview"],
            item._data["id"],
            "✗ preview data doesn't exist, downloading image",
        )
    else:
        rprint("[green] ✓ ", "required data exists for preview image")
    # print success info
    rprint("[blue]Preview image saved at:[/blue]")
    print(paths["preview"])
    # prompt a confirm option
    response = input(
        "Are you sure you want to see an enhanced version of the image at the path shown above? [Y/n]"
    )
    return handle_prompt_response(response)
Esempio n. 3
0
def download_landsat_data(landsat_item, bands):

    # get paths w.r.t. id
    paths = file_paths_wrt_id(landsat_item._data["id"])
    # save bands generically
    for band in bands:
        band_filename = paths["b%s" % band]
        if not data_file_exists(band_filename):
            save_to_file(
                landsat_item.assets["B{}".format(band)]["href"],
                band_filename,
                landsat_item._data["id"],
                "✗ required data doesn't exist, downloading %s %s" %
                (band_tag_map["b" + str(band)], "band"),
            )
        else:
            rprint(
                "[green] ✓ ",
                "required data exists for {} band".format(
                    band_tag_map["b" + str(band)]),
            )

    return landsat_item._data["id"]