64 stac search
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install -U leafmap
# !pip install -U leafmap
In [2]:
Copied!
import leafmap
import leafmap
In [3]:
Copied!
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]
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]
In [4]:
Copied!
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
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
Out[4]:
<pystac_client.item_search.ItemSearch at 0x7f097bb72250>
In [5]:
Copied!
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_collection=True,
)
# search
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_collection=True,
)
# search
In [6]:
Copied!
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_gdf=True,
)
search.head()
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_gdf=True,
)
search.head()
Out[6]:
geometry | created | platform | constellation | instruments | eo:cloud_cover | proj:epsg | mgrs:utm_zone | mgrs:latitude_band | mgrs:grid_square | ... | s2:datastrip_id | s2:granule_id | s2:reflectance_conversion_factor | datetime | s2:sequence | earthsearch:s3_path | earthsearch:payload_id | earthsearch:boa_offset_applied | processing:software | updated | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | POLYGON ((-123.00025 47.85369, -121.53274 47.8... | 2022-11-06T15:26:41.911Z | sentinel-2b | sentinel-2 | [msi] | 64.642105 | 32610 | 10 | T | ET | ... | S2B_OPER_MSI_L2A_DS_EPAE_20201231T212743_S2020... | S2B_OPER_MSI_L2A_TL_EPAE_20201231T212743_A0199... | 1.034125 | 2020-12-31T19:21:21.475000Z | 0 | s3://sentinel-cogs/sentinel-s2-l2a-cogs/10/T/E... | roda-sentinel2/workflow-sentinel2-to-stac/6658... | False | {'sentinel2-to-stac': '0.1.0'} | 2022-11-06T15:26:41.911Z |
1 | POLYGON ((-123.00025 47.85369, -123.00025 46.8... | 2023-08-18T22:50:02.992Z | sentinel-2b | sentinel-2 | [msi] | 83.644599 | 32610 | 10 | T | ET | ... | S2B_OPER_MSI_L2A_DS_S2RP_20230304T134741_S2020... | S2B_OPER_MSI_L2A_TL_S2RP_20230304T134741_A0199... | 1.034125 | 2020-12-31T19:21:21.474000Z | 1 | s3://sentinel-cogs/sentinel-s2-l2a-cogs/10/T/E... | roda-sentinel2/workflow-sentinel2-to-stac/81d2... | True | {'sentinel2-to-stac': '0.1.1'} | 2023-08-18T22:50:02.992Z |
2 | POLYGON ((-122.78713 47.85350, -123.00025 47.2... | 2023-08-20T03:19:26.086Z | sentinel-2b | sentinel-2 | [msi] | 21.615067 | 32610 | 10 | T | ET | ... | S2B_OPER_MSI_L2A_DS_S2RP_20230304T070956_S2020... | S2B_OPER_MSI_L2A_TL_S2RP_20230304T070956_A0199... | 1.033888 | 2020-12-28T19:11:24.522000Z | 1 | s3://sentinel-cogs/sentinel-s2-l2a-cogs/10/T/E... | roda-sentinel2/workflow-sentinel2-to-stac/818b... | True | {'sentinel2-to-stac': '0.1.1'} | 2023-08-20T03:19:26.086Z |
3 | POLYGON ((-122.79462 47.85351, -121.53274 47.8... | 2022-11-06T15:29:35.737Z | sentinel-2b | sentinel-2 | [msi] | 22.943574 | 32610 | 10 | T | ET | ... | S2B_OPER_MSI_L2A_DS_EPAE_20201228T211944_S2020... | S2B_OPER_MSI_L2A_TL_EPAE_20201228T211944_A0199... | 1.033888 | 2020-12-28T19:11:24.522000Z | 0 | s3://sentinel-cogs/sentinel-s2-l2a-cogs/10/T/E... | roda-sentinel2/workflow-sentinel2-to-stac/e6b4... | False | {'sentinel2-to-stac': '0.1.0'} | 2022-11-06T15:29:35.737Z |
4 | POLYGON ((-123.00025 47.85369, -123.00025 46.8... | 2023-07-18T07:29:04.662Z | sentinel-2a | sentinel-2 | [msi] | 98.842812 | 32610 | 10 | T | ET | ... | S2A_OPER_MSI_L2A_DS_S2RP_20230305T133645_S2020... | S2A_OPER_MSI_L2A_TL_S2RP_20230305T133645_A0287... | 1.033680 | 2020-12-26T19:21:22.739000Z | 1 | s3://sentinel-cogs/sentinel-s2-l2a-cogs/10/T/E... | roda-sentinel2/workflow-sentinel2-to-stac/8387... | True | {'sentinel2-to-stac': '0.1.1'} | 2023-07-18T07:29:04.662Z |
5 rows × 42 columns
In [7]:
Copied!
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_assets=True,
)
# search
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_assets=True,
)
# search
In [8]:
Copied!
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_info=True,
)
# search
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_info=True,
)
# search
In [9]:
Copied!
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_links=True,
)
search
search = leafmap.stac_search(
url=url,
max_items=10,
collections=[collection],
bbox=bbox,
datetime=time_range,
get_links=True,
)
search
Out[9]:
['https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201231_0_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201231_1_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201228_1_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201228_0_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_10TET_20201226_1_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_10TET_20201226_0_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_10TET_20201223_1_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_10TET_20201223_0_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201221_1_L2A', 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_10TET_20201221_0_L2A']
Search and visualize open geospatial dataset interactively
In [10]:
Copied!
leafmap.show_youtube_video("https://youtu.be/7OEraGYOWiU")
leafmap.show_youtube_video("https://youtu.be/7OEraGYOWiU")
Out[10]:
In [11]:
Copied!
m = leafmap.Map(center=[37.7517, -122.4433], zoom=8)
m
m = leafmap.Map(center=[37.7517, -122.4433], zoom=8)
m
Out[11]:
The search results can be accessed using one of the following methods:
In [12]:
Copied!
# m.stac_gdf # The GeoDataFrame of the STAC search results
# m.stac_gdf # The GeoDataFrame of the STAC search results
In [13]:
Copied!
# m.stac_dict # The STAC search results as a dictionary
# m.stac_dict # The STAC search results as a dictionary
In [14]:
Copied!
# m.stac_item # The selected STAC item of the search result
# m.stac_item # The selected STAC item of the search result