Skip to main content

Simple H3 and S2 map visualizations for Streamlit

Project description

streamlit-hexviz 🗺️

Simple H3 and S2 map visualisations for Streamlit.

import streamlit_hexviz as shv

# One line: bin points → hexagons → colour-coded choropleth
shv.h3_map(df, lat="lat", lon="lon", weight="sales")

# Continuous heatmap
shv.h3_heatmap(df, lat="lat", lon="lon")

# Pre-indexed data (from a DB query)
shv.h3_choropleth(df, h3_col="h3_index", value_col="count")

# S2 grid
shv.s2_map(df, lat="lat", lon="lon", level=12)

Sidebar controls for resolution, colour scale, opacity, and 3-D extrusion are injected automatically — no boilerplate required.

Screenshots

H3 hexagon choropleth (simple app)

H3 hexagon choropleth

S2 choropleth

S2 choropleth


Installation

pip install streamlit-hexviz
# S2 support (optional):
pip install "streamlit-hexviz[s2]"

API reference

shv.h3_map(df, ...) — choropleth from raw points

Parameter Type Default Description
df DataFrame required Input data with coordinate columns
lat, lon str "lat", "lon" Coordinate column names
resolution int 7 H3 resolution (0-15)
weight str | None None Column to aggregate; None = count points
agg str "sum" "sum", "mean", "count", "max", "min"
transform str "linear" "linear", "log", "quantile"
colour_scale str "viridis" viridis, plasma, heat, blues, reds, greens
alpha int 200 Fill opacity 0-255
extruded bool False 3-D bar chart mode
elevation_scale float 100 Vertical exaggeration (extruded only)
map_style str "dark" "dark", "light", "road", "satellite"
tooltip str | None None HTML tooltip; use {value}, {h3_index}
use_sidebar_controls bool True Inject resolution/colour controls into sidebar
key str | None None Streamlit widget key prefix

Returns: aggregated DataFrame with columns h3_index, value, lat, lon, fill_color, geometry.


shv.h3_heatmap(df, ...) — continuous density heatmap

Same coordinate params. Extra params: radius_pixels (default 40).


shv.h3_choropleth(df, ...) — pre-indexed data

Parameter Default Description
h3_col "h3_index" Column containing H3 cell tokens
value_col "value" Column to visualise

shv.s2_map(df, ...) — S2 grid (optional extra: pip install "streamlit-hexviz[s2]")

Same as h3_map but uses level (0-30) instead of resolution.


Transforms

Name Best for
linear Uniformly distributed values
log Heavy-tailed count distributions
quantile Any distribution; highlights relative rank

H3 resolution guide

Resolution Avg area Typical use
5 ~252 km² Country-level
7 ~5.2 km² City-level
9 ~0.1 km² Neighbourhood
11 ~0.001 km² Block-level

Running the demo

Visualization the basic maps

pip install streamlit h3 pydeck numpy pandas
streamlit run examples/app_simple.py

More interactive app demo

pip install streamlit h3 pydeck numpy pandas
streamlit run examples/demo_app.py

Contributing

PRs welcome! See CONTRIBUTING.md.


License

MIT

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

streamlit_hexviz-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_hexviz-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_hexviz-0.1.0.tar.gz.

File metadata

  • Download URL: streamlit_hexviz-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for streamlit_hexviz-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec19f857950985ae67a0b15687939a6dac045cd41e3dcfe4bd2f094ee3720cb6
MD5 a5069de2a03276def62308c024590fa6
BLAKE2b-256 cc386471dd4bb9de3d7ede86ec793d1bc673115243e17f7207dd9680f6dacb14

See more details on using hashes here.

File details

Details for the file streamlit_hexviz-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_hexviz-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97840a240cc27dd6ac972295a732c726c03652c265208c1d6bbde174f91bc094
MD5 bc208bc6f9d71063df1fbd7d973b3837
BLAKE2b-256 cfede6945b797f5afd6423a5dd53fe2715eb3186d7221bc1f2444c4609bf52fc

See more details on using hashes here.

Supported by

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