Skip to content

64 stac search

image image image

Uncomment the following line to install leafmap if needed.

1
# !pip install -U leafmap
1
import leafmap
1
2
3
4
url = "https://earth-search.aws.element84.com/v1/"
collection = "sentinel-2-l2a"
time_range = "2020-12-01/2020-12-31"
bbox = [-122.2751, 47.5469, -121.9613, 47.7458]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    query={"eo:cloud_cover": {"lt": 10}},
    sortby=[{"field": "properties.eo:cloud_cover", "direction": "asc"}],
)
search
1
2
3
4
5
6
7
8
9
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    get_collection=True,
)
# search
1
2
3
4
5
6
7
8
9
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    get_gdf=True,
)
search.head()
1
2
3
4
5
6
7
8
9
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    get_assets=True,
)
# search
1
2
3
4
5
6
7
8
9
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    get_info=True,
)
# search
1
2
3
4
5
6
7
8
9
search = leafmap.stac_search(
    url=url,
    max_items=10,
    collections=[collection],
    bbox=bbox,
    datetime=time_range,
    get_links=True,
)
search

Search and visualize open geospatial dataset interactively

1
leafmap.show_youtube_video("https://youtu.be/7OEraGYOWiU")
1
2
m = leafmap.Map(center=[37.7517, -122.4433], zoom=8)
m

The search results can be accessed using one of the following methods:

1
# m.stac_gdf  # The GeoDataFrame of the STAC search results
1
# m.stac_dict  # The STAC search results as a dictionary
1
# m.stac_item  # The selected STAC item of the search result