PDA

View Full Version : Heatmaps



Hai-Etlik
12-03-2012, 10:20 PM
So, one of the things I was working on recently at work was logging the bounding boxes of WMS requests made to GeoServer. This obviously made for a lot of overlapping boxes, which is hard to display with normal symbolization. Geoserver does however have some interesting alternative forms of symbolization, including something called a "heatmap" This is a surface made by drawing the centres of the features into the map and keeping track of how many times they overlap. Then the whole surface is blurred. Then the whole thing is normalized so the maximum ls 1.0.

Now that normalizing of overlapping levels is really useful, but I needed to preserve the shape. With a bit of work though, I was able to make two changes. Making it render the bounding box of a feature, and normalizing the minimum as well as the maximum to preserve contrast when zooming in.

The result looked like this

50371

Now, bounding boxes are nice and all I needed for the project I was working on, but it would be even better to render the feature properly. because of the way Heatmap works, it can't just leverage a stock graphics library like Java2D (which most of the rest of GeoServer uses for vector to raster.)

I didn't have time for polygons (at this point I was on my own time), but rendering a linestring is pretty straight forward. So I added that, took some GPS tracks from my time delivering pizza, and got a pretty cool looking map.

50372

Korash
12-04-2012, 12:14 PM
That is NEAT!!

I am thinking Star Lanes....or initial layout for a town, or city with enough samples, using the brightness for poulation usage...or a kobold warren....or trade routes......ad infinitum....

Hai-Etlik
12-04-2012, 07:17 PM
That is NEAT!!

I am thinking Star Lanes....or initial layout for a town, or city with enough samples, using the brightness for poulation usage...or a kobold warren....or trade routes......ad infinitum....

Well, really this is something where you need the data to begin with and what I've done is create a way to visualize it, although it could be used for some analysis of the data too. For instance, you could drape a road network over the heatmap surface to set its M ordinates. Then you would have the traffic levels on the roads.

Korash
12-04-2012, 07:43 PM
Yeah, I get it about having the data, but really, all we have to do is pick up a GPS and start gathering the info ;)

Jaxilon
12-06-2012, 11:34 AM
What is your goal in doing this Hai? You said it was work related so I'm wondering what the purpose is. That might help me to understand what bounding boxes are too :)

Hai-Etlik
12-06-2012, 03:54 PM
What is your goal in doing this Hai? You said it was work related so I'm wondering what the purpose is. That might help me to understand what bounding boxes are too :)

Heatmaps are a way of showing data that has a lot of overlap or clustering and where the density of that overlap/clustering is the important thing. In my case, I'm working with a GIS Server. It receives requests for sections of a map along the lines of: "Give me the map from N 40 to N 50 and E 130 to E 120". That range of coordinates defines a "box" that forms the "boundary" of the request and we call it a Bounding Box. I added the ability to log the bounding boxes of requests so the people running a server can figure out which parts of the map are under higher load and might benefit from more caching.

Obviously this produces a data set that is just a LOT of overlapping boxes which will cover each other up. So you can't just display them normally. So I took the Heatmap we already had, which just worked with points, and made it work with other geometries. But all my data was just boxes, and properly rasterizing geometries is rather more complex than just filling a box, so I cheated and made it render the bounding box of the geometry (The box that just fits the geometry) rather than the geometry itself. This was fast and easy. the result is the top image, you can see where more requests were made as the heatmap is brighter.

Adding support for Line Strings wasn't that hard either, and I thought it would look cool, so I did it on my own time. It's useful for showing things like traffic levels if you use a set of routes as the input features (as in the case of my pizza delivery map). When I have time, I plan to add proper support for Polygons/Multipolygons as well to round it all out.

Here's an illustration of Bounding Boxes:

50392

The red box is the bounding box for the grey polygon in the coordinate system shown by the grid. The green and blue shapes are the bounding boxes of that same polygon in other coordinate systems, transformed into the coordinate system of the image.

Jaxilon
12-06-2012, 06:02 PM
Great explaination, thanks. I kind of had an idea along those lines but it wasn't strongly defined.

amberroberts09
12-11-2012, 06:05 AM
Heat map is geographical representation of data in a form of colored matrix.