Пример #1
0
def buscarResultadosSatelite(minLon, minLat, maxLon, maxLat, minDate, maxDate,
                             maxCloudCover, satellite):
    search = Search.search(bbox=[minLon, minLat, maxLon, maxLat],
                           datetime=minDate + '/' + maxDate,
                           property=["eo:cloud_cover<" + str(maxCloudCover)],
                           collection=satellite)
    items = search.items()
    return items
def download_images():
    # Bounding box (min lon, min lat, max lon, max lat)
    search = Search.search(
        bbox=[-123.268003, 49.170589, -122.970262, 49.326161],
        datetime="2019-01-01/2019-06-30",
        property=["eo:cloud_cover<20"],
        collection="landsat-8-l1")
    items = search.items(limit=10)
    matadata = items.save('sat-search-images_data.json')
    print("Downloaded satellite images information:")
    print(items.summary(['date', 'id', 'eo:cloud_cover']))
    filenames = items.download("thumbnail")
Пример #3
0
def main(items=None,
         printmd=None,
         printcal=None,
         printassets=None,
         found=False,
         filename_template='${collection}/${date}/${id}',
         save=None,
         download=None,
         requester_pays=False,
         headers=None,
         **kwargs):
    """ Main function for performing a search """

    if items is None:
        ## if there are no items then perform a search
        search = Search.search(headers=headers, **kwargs)
        if found:
            num = search.found(headers=headers)
            print('%s items found' % num)
            return num
        items = search.items(headers=headers)
    else:
        # otherwise, load a search from a file
        items = ItemCollection.open(items)

    print('%s items found' % len(items))

    # print metadata
    if printmd is not None:
        print(items.summary(printmd))

    # print calendar
    if printcal:
        print(items.calendar(printcal))

    if printassets:
        print(items.assets_definition())

    # save all metadata in JSON file
    if save is not None:
        items.save(filename=save)

    # download files given `download` keys
    if download is not None:
        if 'ALL' in download:
            # get complete set of assets
            download = set([k for i in items for k in i.assets])
        for key in download:
            items.download(key=key,
                           filename_template=filename_template,
                           requester_pays=requester_pays)

    return items
Пример #4
0
def main(items=None,
         printmd=None,
         printcal=False,
         found=False,
         save=None,
         download=None,
         requestor_pays=False,
         **kwargs):
    """ Main function for performing a search """

    if items is None:
        ## if there are no items then perform a search
        search = Search.search(**kwargs)
        if found:
            num = search.found()
            print('%s items found' % num)
            return num
        items = search.items()
    else:
        # otherwise, load a search from a file
        items = ItemCollection.load(items)

    print('%s items found' % len(items))

    # print metadata
    if printmd is not None:
        print(items.summary(printmd))

    # print calendar
    if printcal:
        print(items.calendar())

    # save all metadata in JSON file
    if save is not None:
        items.save(filename=save)

    # download files given `download` keys
    if download is not None:
        if 'ALL' in download:
            # get complete set of assets
            download = set([k for i in items for k in i.assets])
        for key in download:
            items.download(key=key,
                           path=config.DATADIR,
                           filename=config.FILENAME,
                           requestor_pays=requestor_pays)

    return items
Пример #5
0
def main(items=None, printmd=None, printcal=False, found=False,
         save=None, download=None, requestor_pays=False, **kwargs):
    """ Main function for performing a search """
    
    if items is None:
        ## if there are no items then perform a search
        search = Search.search(**kwargs)
        if found:
            num = search.found()
            print('%s items found' % num)
            return num
        items = search.items()
    else:
        # otherwise, load a search from a file
        items = Items.load(items)

    print('%s items found' % len(items))

    # print metadata
    if printmd is not None:
        print(items.summary(printmd))

    # print calendar
    if printcal:
        print(items.calendar())

    # save all metadata in JSON file
    if save is not None:
        items.save(filename=save)

    # download files given `download` keys
    if download is not None:
        if 'ALL' in download:
            # get complete set of assets
            download = set([k for i in items for k in i.assets])
        for key in download:
            items.download(key=key, path=config.DATADIR, filename=config.FILENAME, requestor_pays=requestor_pays)

    return items
Пример #6
0
        if OSM:
            OSM_DATA = CONFIGS["osm_query"]
    except KeyError as error:
        print("Invalid Config file, propaly not all ")
        print(error)
        sys.exit()
    assert os.path.exists(JSON_PATH), "Json file does not exist"

    try:
        FEATURES = load_geojson_features_to_dict(JSON_PATH)
        if OSM:
            FEATURES = grab_osm_data(OSM_DATA, FEATURES)
        BBOX = get_bbox(FEATURES)
        GEOM_LIST = get_geom_list(FEATURES, BUFFER_DISTANCE)
        SEARCH = Search.search(bbox=BBOX,
                               datetime=DATETIME_FRAME,
                               collection=COLLECTION,
                               property=PROPERTY)

        ITEMS = SEARCH.items()
        print("Found {} tiles matching".format(SEARCH.found()))
        DATE_LIST = []
        NDVI_LIST = []

        for i in range(len(FEATURES)):
            NDVI_LIST.append([])
            DATE_LIST.append([])

        for item_counter, item in enumerate(ITEMS):
            print("Processing Tile {} of {}".format(item_counter + 1,
                                                    len(ITEMS)))
            URL_PAIR = get_url_pair(item, COLLECTION)
Пример #7
0
import numpy as np
from pathlib import Path

# Must be installed via pip; conda version outdated.
from satsearch import Search

# Specify geometry
geom = {
    "type":
    "Polygon",
    "coordinates": [[[-66.3958740234375, 43.305193797650546],
                     [-64.390869140625, 43.305193797650546],
                     [-64.390869140625, 44.22945656830167],
                     [-66.3958740234375, 44.22945656830167],
                     [-66.3958740234375, 43.305193797650546]]]
}

# Search for all landsat-8-l1 data intersecting with that geometry
search = Search.search(intersects=geom, collection='landsat-8-l1')

# Collect urls/items having to do with that data
items = search.items()

# print summary
print(items.summary())

# Get just one item and download all associated assets (TIFs for bands B0-B11):
# Each item with all bands is roughly 1/2 a gb?
items = search.items(limit=1)
print(items.summary())
items.download_assets(path=str(Path.cwd()) + '/${date}')
Пример #8
0
    "coordinates": [[[-66.3958740234375, 43.305193797650546],
                     [-64.390869140625, 43.305193797650546],
                     [-64.390869140625, 44.22945656830167],
                     [-66.3958740234375, 44.22945656830167],
                     [-66.3958740234375, 43.305193797650546]]]
}

search = Search(intersects=geom)
print('intersects search: %s items' % search.found())

query = {"eo:cloud_cover": {"lt": 10}, "collection": {"eq": "landsat-8-l1"}}

search = Search(query=query)
print('%s items found' % search.found())

search = Search.search(
    property=["eo:cloud_cover<10", "collection=landsat-8-l1"])
print('%s items found' % search.found())

# or use collection shortcut
search = Search.search(collection='landsat-8-l1',
                       property=["eo:cloud_cover<10"])
print('%s items found' % search.found())

#search = Search(bbox=[-110, 39.5, -105, 40.5],
#               datetime='2018-02-01/2018-02-04',
#               property=["eo:cloud_cover<5"])
#print('%s items' % search.found())

items = search.items()
print('%s items' % len(items))
print('%s collections' % len(items._collections))
Пример #9
0
def ls_make_hits_dataframe(aoi_geojson_file, time):

    pids, bands, paths, rows, dates, reds = [], [], [], [], [], []
    greens, blues = [], []
    nirs, pixel_qas = [], []


    print("return_stac_hits")
    geom = return_geo_query_body(aoi_geojson_file, time = time)

    date_range = _return_date_query(time)

    search = Search.search(intersects=geom,
            datetime=date_range,
            collection='landsat-8-l1')
    print('intersects search: %s items' % search.found())
    items = search.items()
    print('%s items' % len(items))
    print('%s collections' % len(items._collections))
    print(items._collections)


    for item in items:
        #print(item)

        product_id = item.id

        path = product_id[3:6]
        row = product_id[6:9]


        #print ("PATH ROW", path, row)
        bandd = _return_band_dict(item)
        #print(bandd['red'])

        file_part = bandd['red'].split('/')[-1]
        print(file_part)
        product = file_part[0:9]
        band = file_part.split('_')[-1]

        date = str(item.date)

        red = bandd['red']

        green = bandd['green']
        blue = bandd['blue']
        nir = bandd['nir']
        pixel_qa = bandd['BQA']


        pids.append(product)
        bands.append(band)
        paths.append(path)
        rows.append(row)
        dates.append(date)
        reds.append(red)
        greens.append(green)
        blues.append(blue)
        nirs.append(nir)
        pixel_qas.append(pixel_qa)



    panda_input_dict = dict(product=pids, band=bands, path=paths, row=rows, date=dates, red=reds, green=greens, blue=blues, nir=nirs, pixel_qa=pixel_qas)

    DF = pd.DataFrame(panda_input_dict, columns=['product', 'band', 'path', 'row', 'date', 'red', 'green', 'blue', 'nir', 'pixel_qa'])

    cols = DF.columns.tolist()

    return DF