$ show sethoscope/heatmap
This repository is a Python application/library for generating 2D heatmaps from coordinate data. The core module src/heatmap77/heatmap.py implements a complete pipeline: file readers parse plain text, CSV, GPX, and ESRI Shapefile inputs; coordinate systems and projections (equirectangular, mercator) map lat/lon to pixel space; linear and gaussian kernels spread point mass; sparse matrix classes accumulate contributions with optional decay; and an ImageMaker renders the result to PNG/PPM, optionally compositing over OSM tiles or custom backgrounds. The package exposes both a CLI entry point (heatmap77) and a programmatic API used by the examples.
The LLM identified 4 files worth highlighting for reuse:
The SummingMatrix, MaxingMatrix, and AppendingMatrix classes implement a sparse grid accumulation pattern with optional decay. They are self-contained, operate on numpy arrays, and can be extracted for any density or histogram accumulation task where overlapping contributions need to be summed, maxed, or appended over time.
The FileReader hierarchy (PlainFileReader, CSVFileReader, GPXFileReader, ShapeFileReader, AutoFileReader) provides a clean, extensible interface for parsing different coordinate input formats. Each reader implements a common iterator protocol, making it easy to add new formats or reuse the pattern in other data ingestion tools.
The ColorMap class maps scalar heat values to colors using either an HSV range or a custom gradient image, with caching and step interpolation. It is a reusable visualization component that can be lifted into any rendering pipeline requiring smooth, configurable color mapping.
The LatLon and Projection classes encapsulate geographic coordinate transformations, including equirectangular and mercator projections with configurable scale. They are small, dependency-light, and reusable for any project needing lat/lon to pixel-space conversion.