Geospatial Indexing with H3 & S2 — Two Apps + a New Component (streamlit-hexviz)

Hi community :waving_hand:

I’d like to share some work I’ve been doing around geospatial indexing — a technique that converts point coordinates into larger geometric shapes (like hexagons), effectively turning a two-dimensional spatial problem into a standard index lookup. This makes spatial queries dramatically faster and more scalable.

Two of the most prominent tools for this are:

  • H3 (by Uber) — hexagon-based indexing

  • S2 (by Google) — sphere-based cell indexing


App 1 — H3 Explorer :backhand_index_pointing_right: https://h3-example-app.streamlit.app/

My first experiment: an interactive app to visualize how H3 indexing works. You can explore how raw coordinates get mapped into hexagonal cells at different resolutions — a great way to build intuition for the concept.


App 2 — Hexviz Example App :backhand_index_pointing_right: https://app-hexviz-example-app.streamlit.app/

Built on top of my new component (see below), this app demonstrates converting latitude/longitude points into H3 hexagons and making routes and movement patterns visible on a map.


The Component — streamlit-hexviz

To make hexagon-based map visualization reusable, I packaged the core logic into a dedicated Streamlit component: streamlit-hexviz. It lets you turn lat/lon coordinates into H3 hexagons with minimal code.

:warning: Note: This is an early release — not all planned features are covered yet, but it’s functional and I’d love early feedback!


Happy to answer questions about geospatial indexing, H3, or the component itself. Feedback and ideas very welcome! :folded_hands:

Hey again :slight_smile:

Happy to share that the new version 0.2.0 is available now.

The optional import of A5 (https://a5geo.org/) is now introduced.

Example on earthquakes

import pandas as pd
import streamlit_hexviz as shv

data = pd.read_csv('data/all_month.csv')
shv.a5_map(df=data, lat='latitude', lon='longitude', use_sidebar_controls=True)

The sidebar controls is a native streamlit option and enables the switch between resolutions, change of color scheme.
The tool also allows to aggregate by a column , not only by the count, thus the option ‘Value transform’ enables to look at log / linear options.

Usability

Generally, the tool is not focused on any of the geo spatial index tools, and thus the switch between them should be as easy as possible, and by replacing a5_map by h3_map or s2_map. the tool is switching to the other geo spatial index.

import pandas as pd
import streamlit_hexviz as shv

data = pd.read_csv('data/all_month.csv')
shv.h3_map(df=data, lat='latitude', lon='longitude', use_sidebar_controls=True)