Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have a list of temperature levels (0 - 30 degrees) in different parts of a city. I would like to visualize the different temperature levels in the different parts of the city. Hot places should be displayed in red and cold ones blue. If the user zoom out he will get the avarage temperature color of the city and if zoomed in he will get the average color of the temperate color of that place.

I think that what I need is referred to as heatmaps. Is that the correct?

I am not too expert in visualization techniques and would appreciate explanatory pseudocode to illustrate the internal workings and main building blocks for heatmap algorithms, and how I could handle the zooming.

share|improve this question

migrated from May 19 '12 at 16:25

This question came from our site for professional and enthusiast programmers.

heatmaps to display temperature variations? –  Marc B May 18 '12 at 20:21
Sure, heatmaps may be for temperature! nevertheless when i have used some heatmap apis I got some strange effect regarding zooming the map which made me re-consider thinking about heatmaps. (if zoomed out the heatmap shows red (hot) because of the density of measurement points but in reality if you zoom in the measurements are not necessarily red (hot) they might be a number of orange or blue points. I could not really understand why therefore I asked about the internal working to find out how the staff really works) –  Future2020 May 18 '12 at 20:31
Also consider org.jfree.chart.renderer.xy.XYBlockRenderer. –  trashgod May 19 '12 at 14:20

1 Answer 1

up vote 9 down vote accepted

That sort of thing is exactly what a heatmap is for. As to how to build one, think about a collection of points on the map laid out in a grid. Each point has a temperature associated with it; you then map each temperature value to a color, say with

Red:    80
Orange: 70

and so on. That's your basic heatmap.

Now, in the real world you don't generally have exactly rectangular grids, so you have to interpolate. That means finding the nearest points for which you have data and computing an assumed temperature based on some rule. Usually this would be linear -- that is, if you want to compute the value for a point halfway between two other points, you would assign it half the difference in temperatures.

This looks like a decent article here:

Now, when you do the zooming, all you do is compute a new matrix of numbers for the new grid, map the old vertices to the new grid vertex and average the values.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.