https://github.com/aazuspan/stacmap
Explore STAC items with an interactive map
https://github.com/aazuspan/stacmap
earth-observation explore folium geospatial interactive-map spatiotemporal-asset-catalog stac
Last synced: 16 days ago
JSON representation
Explore STAC items with an interactive map
- Host: GitHub
- URL: https://github.com/aazuspan/stacmap
- Owner: aazuspan
- License: mit
- Created: 2022-05-11T05:58:01.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-25T23:07:17.000Z (over 2 years ago)
- Last Synced: 2025-02-13T17:02:53.810Z (2 months ago)
- Topics: earth-observation, explore, folium, geospatial, interactive-map, spatiotemporal-asset-catalog, stac
- Language: Python
- Homepage: https://stacmap.readthedocs.io/en/latest/
- Size: 235 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stacmap
[](https://badge.fury.io/py/stacmap)
[](https://stacmap.readthedocs.io/en/latest/)

[](https://nbviewer.org/github/aazuspan/stacmap/blob/main/docs/source/tutorials/quickstart.ipynb)
[](https://mybinder.org/v2/gh/aazuspan/stacmap/HEAD?labpath=docs%2Fsource%2Ftutorials%2Fquickstart.ipynb)
[](https://codecov.io/gh/aazuspan/stacmap)Create interactive maps of [STAC](https://stacspec.org/) 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
```bash
$ pip install stacmap
```# Quickstart
`stacmap.explore` creates an interactive [Folium](https://python-visualization.github.io/folium/) map from STAC items or collections.
```python
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](https://stacmap.readthedocs.io/en/latest/) for details or try out an [interactive notebook](https://mybinder.org/v2/gh/aazuspan/stacmap/HEAD?labpath=docs%2Fsource%2Ftutorials%2Fquickstart.ipynb) 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:
```python
from pystac_client import Clientcatalog = 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
``` python
!pip install stacmapimport stacmap
stacmap.explore(
items,
prop="eo:cloud_cover",
bbox=bbox
)
`````` python
!pip install geopandas folium mapclassify matplotlibimport geopandas as gpd
import shapely
import foliumgdf = 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](https://stacmap.readthedocs.io/en/latest/tutorials/geopandas.html) for tips on switching to the `stacmap` API.