The first version of my lightning map visualizer was cool, but there were multiple things that nagged at me. The biggest one being that it didn’t include a heatmap visualization over the map. Something to indicate the density of lightning strikes. It only had the storm outlines and the lightning playback. The reason I didn’t include a heatmap was that I didn’t have a way to quickly get the data for it. I did have some ideas for how to perhaps get at the data in a smarter and faster way, and after a few sessions with Claude with some very strict steering, it’s done. The heatmap uses a stable color scale, so a shade is comparable across time. Scrolling the timeline adds and removes sections from the heatmap as the strikes go in and out of view. I’m very happy with how it turned out.
Have a look at https://thor.engdal.fi/.
Some highlights from the update:
- The aforementioned heatmap with a stable scale, so a shade is comparable across time
- A “Top days” list, a menu with a list of the days with the most strikes in the region that is in view on the map
- Lightning data all the way from 2014 to today is now included. I could backfill more from the Finnish Meteorological Institute (FMI), but as I understand it, coverage is not as great across the whole region before 2014, so I would have to inform the user about that if I do it.
- A “Go to” menu and a welcome modal (the question-mark button on the map), in addition to the “Top days” menu I mentioned earlier, to hopefully teach users what the app is about.
The heatmap
What had prevented me from including a heatmap earlier was that my previous attempts were too slow. I want the UI to update as close to instantly as possible. I had already gotten the timeline charts to update very quickly on map operations (pans and zooms) and timeline scrolls thanks to pre-calculating strike counts per 15min interval, per cell in a grid, per 4 different grid size levels. The SQLite queries could then sum the counts from cells within the view and time range, big cells in the middle of the view and smaller ones at the edges. This was very fast for the timeline charts. But I didn’t manage to get the query for the heatmap fast enough tho due to the large number of rows involved. Another pre-calculation step was the solution: a table where each row holds all cell strike counts per 15min per grid size, so there’s a single row per 15min interval per grid size. Yes, a row holds all cell strike counts in an interval in a binary blob. Not the prettiest design, but it’s very fast to get out of SQLite, filter and serialize for sending to the browser. The different grid sizes let the app use a grid with fewer cells when zoomed out, and one with higher detail when zoomed in. Maplibre gets the cell counts and uses a WebGL layer to paint a nice looking heatmap.
Explaining what the app is to users
One of the big challenges with an app like this is how to teach the user
- What is possible to do
- What things mean
I don’t think I’m quite there yet, but I’m getting closer. Ideally there would be no need for any text or explanation, as users don’t tend to read them anyway, but there have to be explanations written down. Things can be misinterpreted in wild ways, and there needs to be a chance for the user to look things up.
The “Top days” list and both timelines (the charts under the map) reflect the current map viewport. They update live as the user pans and zooms the map. That makes it possible to see the days with most lightning at any location. I think this is pretty cool, and it’s at the center of the app. All design decisions have fallen out from it. But I don’t know if it’s intuitive to a user that that’s what’s happening. Hopefully it is, as both the list and the timelines change on pan and zoom, but maybe it isn’t. There’s now text that says how it works.
Originally I made the app for desktop, for large screens and mouse. Later, as my ambition grew, I made it work better for mobile. I think the fact that mobile came later still shows. Especially the timelines are kinda iffy on mobile. For desktop they were meant to be a quick way to scroll over large amounts of time while highlighting busy days with the color scale, but on mobile I worry esp. the date timeline (the one with teal color scale) might not work so well. A date picker in a modal might be a better UI model on mobile.
A browser limitation
As I backfilled more data and went from 5 years to over a decade of lightning, I bumped into a browser limitation I knew about, but for some reason had completely disregarded. There’s a limit to how wide HTML elements can be! The timelines were both sized as wide as required to fit all the historic data, for scrolling purposes. The app never loaded all that data at once, of course. That would be slow in all sorts of ways, but the full width was used for the scrolling. As the historic data was expanded, the elements reached their max allowed width and it just wasn’t possible to scroll beyond a certain point anymore.
Not a huge deal. The timelines already used virtual scrolling, but with real scroll positions. Now they use truly virtual scrolling with some clever positioning tricks in order to avoid the full-width container elements. The timelines keep pretty large container elements and position scroll pages relative to each other within that, sometimes resetting the offset in order to keep within the container. The app didn’t show timeline scroll bars before the change, and now it really can’t show them. I guess fake scroll bars could be implemented, but I don’t think there’s a need for them anyway.
Future work
Let the user step through the lightning playback
The replay functionality is mostly just a nice-looking effect atm. It super-quickly plays through the lightning in view on the map and that’s it. I’d like to be able to step through each 5/15min slice. Maybe let the user select the playback speed. As I write this I feel a need to explicitly say that this is a toy app. It’s for nerds that like to look at stuff like this. :) It’s also a tech demo of sorts.
Date navigation on mobile
Perhaps a more traditional date picker would work better on mobile.