hextraj#
Hex-labelling of trajectory data.
Maps lon/lat positions to a projected hexagonal grid and provides tools for aggregation and connectivity analysis.
hex_counts— heat maps and density aggregationhex_connectivity— origin-destination matriceshex_connectivity_power— multi-generation transport probabilitieshex_connectivity_dask— lazy dask-native connectivity for large datasetsFull dask support throughout
Installation#
pip install git+https://github.com/willirath/hextraj.git@main
For dask, scipy, and cartopy support:
pip install "hextraj[full] @ git+https://github.com/willirath/hextraj.git@main"
Quick example#
from hextraj import HexProj
hp = HexProj(lon_origin=-3.0, lat_origin=54.0, hex_size_meters=50_000)
# Label positions -> int64 hex IDs
hex_ids = hp.label(lon, lat)
# Build a GeoDataFrame with Polygon geometries
gdf = hp.to_geodataframe(hp.region_of_hexes(region_polygon))
gdf["count"] = counts.reindex(gdf.index).fillna(0)
gdf.plot(column="count", cmap="YlOrRd")
Notebooks
API Reference