Github Binder

Exploring an ItemCollection

Let’s load an ItemCollection of Landsat 8 scenes from the Planetary Computer STAC and preview them with stacmap.explore.

[1]:
import stacmap
import pystac_client
[2]:
catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")

aoi = {"type": "Polygon", "coordinates": [[
    [-112.2068359375, 42.41050500280784],
    [-112.2068359375, 39.25270077697571],
    [-107.9880859375, 39.25270077697571],
    [-107.9880859375, 42.41050500280784],
    [-112.2068359375, 42.41050500280784]
]]}

items = catalog.search(
    collections=["landsat-8-c2-l2"],
    intersects=aoi,
    datetime="2019-06-01/2019-06-10"
).get_all_items()

Calling stacmap.explore with a STAC Collection* will preview the item footprints on an interactive map. Hover over each footprint to see its STAC metadata.

*Currently supported STAC-like types are: pystac.Catalog, pystac.ItemCollection, pystac.Item, collection dictionaries, item dictionaries, and lists of item dictionaries.

[5]:
stacmap.explore(items)
[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Color-Coding

Footprints can be color-coded based on STAC properties using the prop parameter. The default colormap can be replaced with any colorbrewer name using cmap. Additional color maps are supported if matplotlib is installed.

Continuous Properties

By default, numeric properties are colored continuously and given continuous legends. Color map bounds are calculated automatically, but can be overriden by providing vmin and vmax arguments.

[15]:
stacmap.explore(items, prop="view:sun_elevation", cmap="Reds")
[15]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Categorical Properties

Non-numeric properties are treated categorically by default, with a color assigned to each unique value. You can force a numerical field to plot categorically using categorical=True.

[13]:
stacmap.explore(items, prop="proj:epsg", categorical=True)
[13]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Search Extents

Pass a bounding box to bbox or a GeoJSON geometry to intersects to overlay your search bounds.

[14]:
stacmap.explore(items, prop="landsat:wrs_path", intersects=aoi)
[14]:
Make this Notebook Trusted to load map: File -> Trust Notebook