There was a comment on a recent Hacker News thread about a world airport Voronoi map that said “if only there was a webpage/software where someone could click/select points on a map…and a user Voronoi diagram would be created ;-).”
I knew such a tool already existed, but I thought I might as well try to implement one myself, so I put together the pieces:
- The deldir R package can quickly create Voronoi lines for a given set of two-dimensional points.
- Google Maps, since I knew how to handle events like clicking to add a point, dragging the points, and double-clicking to remove. Plus it’s easy to draw the Voronoi lines.
- Shiny can link that quick calculation of Voronoi lines with the front-end maps library API, so that user events and the server-side data stay in sync.
A live demo version is available on our Shiny demo server: https://shiny.modernresearchconsulting.com/create-voronoi
The user interface is pretty simple – just click to add points, drag to change, and double-click to remove, and the Voronoi will update automatically.
There’s also an option to change the lines from straight to geodesics (following the curve of the earth).
The code is on Github and MIT-licensed.
I’d love to add a way to load sets of point at once (US state capitals, 100 tallest mountains, sports arenas, etc) when I have more time to work on this.