Skip to main content

Create interactive maps of STAC items.

Project description

stacmap

PyPI version Documentation Status Testing workflow nbviewer Binder codecov

Create interactive maps of STAC items and collections without the heavy dependencies and boilerplate of geopandas.GeoDataFrame.explore.

Features

  • 🗺️ Explore STAC item footprints
  • 🌈 Color-code items by properties
  • 🖼️ Preview item thumbnails
  • 🪶 Lightweight dependencies (just folium and pystac)

Installation

$ pip install stacmap

Quickstart

stacmap.explore creates an interactive Folium map from STAC items or collections.

import stacmap
from pystac_client import Client

# Find Landsat Collection 2 scenes over an area of interest
catalog = Client.open("https://landsatlook.usgs.gov/stac-server")
items = catalog.search(
    bbox=[-120.9519, 37.2455, -113.4812, 45.1025],
    collections=["landsat-c2l2-srby"],
    datetime="2019-08-01/2019-08-03"
).get_all_items()


# Plot the items on an interactive map, color-coded by cloud cover
stacmap.explore(items, prop="eo:cloud_cover")

Check out the docs for details or try out an interactive notebook in Binder.

Compared to GeoPandas

Let's look at a simple example to see how stacmap simplifies plotting a STAC collection and search bounds over geopandas.

First, we'll load our STAC items:

from pystac_client import Client

catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")

bbox = (-67.008753, -9.96445, -65.615556, -8.57408)

items = catalog.search(
    collections=["sentinel-2-l2a"],
    bbox=bbox,
    datetime="2019-06-01/2019-06-10"
).get_all_items()

Now we'll create an interactive map that shows our items and our bounding box.

stacmap geopandas
!pip install stacmap

import stacmap

stacmap.explore(
    items, 
    prop="eo:cloud_cover", 
    bbox=bbox
)
!pip install geopandas folium mapclassify matplotlib

import geopandas as gpd
import shapely
import folium

gdf = gpd.GeoDataFrame.from_features(
    items.to_dict(), 
    crs="EPSG:4326"
)
bbox_geom = shapely.geometry.mapping(shapely.geometry.box(*bbox))
bbox_layer = folium.GeoJson(bbox_geom)

m = gdf.explore(column="eo:cloud_cover")
bbox_layer.add_to(m)
m

Users coming from geopandas can check out the transition guide for tips on switching to the stacmap API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stacmap-0.0.4.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file stacmap-0.0.4.tar.gz.

File metadata

  • Download URL: stacmap-0.0.4.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for stacmap-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3a4fa294c9309761f13c1e889351facfb3aa2d88b92208378cfe923ed9b2b761
MD5 456a88ec36ebe8b398472ddc73c600f7
BLAKE2b-256 f6747df46375d67118be7675f670a3a6e8cf725210829db7cb152c1f2aeee0aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page