5
$\begingroup$

I am looking to generate a heat map from some data. I have a value and a location (longitude and latitude). I understand generating a colour from the value, however I'm not sure how I would go about generating the matrix to use for this.

I figure it's best to place the location points into buckets essentially (so that I have the same number of buckets as pixels in my map) but I'm not sure how to calculate the values for the buckets where I don't have any readings.

Has anyone got any experience with this?

Thanks!

$\endgroup$
  • $\begingroup$ This might be a question well-suited to the Computational Science Stack Exchange site. If you don't get any good answers here. $\endgroup$ – Patrick87 Mar 1 '13 at 16:52
4
$\begingroup$

You have to interpolate the missing heat values. There's some mathematics that explains this pretty well (man, it's been a while) but, if I recall correctly, the correct physical way to do this (assuming no heat sources in the area being interpolated) is the following:

  1. For each pixel for which there wasn't original data, assign the value of the pixel to the average value of all surrounding pixels.
  2. Repeat (1) until no pixel changes its value by at least some $\epsilon$

To be safe, you should probably double-buffer this process, so that while doing the first step, changing the value of the first pixel doesn't affect the value for the second pixel. Example:

   5.0 4.0 4.0 3.0    5.0 4.0 4.0 3.0    5.0 4.0 4.0 3.0    5.0 4.0 4.0 3.0
   2.0 --- --- 1.0    2.0 3.0 2.5 1.0    2.0 2.6 2.6 1.0    2.0 2.8 2.5 1.0
   1.0 --- --- 3.0 => 1.0 2.0 2.5 3.0 => 1.0 2.4 2.4 3.0 => 1.0 2.3 2.5 3.0
   3.0 3.0 2.0 4.0    3.0 3.0 2.0 4.0    3.0 3.0 2.0 4.0    3.0 3.0 2.0 4.0

=> 5.0 4.0 4.0 3.0
   2.0 2.7 2.6 1.0
   1.0 2.3 2.5 3.0 ...
   3.0 3.0 2.0 4.0

Already the values are beginning to settle down a bit. This is easy and fast to automate, though naturally, you'll only get an approximation. See here and here for more information on the physics and mathematics behind this (and whether this is even applicable to your situation!!!)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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