# Plotting temperature on a map

1. Sep 8, 2007

### DaveC426913

I want to map the temperature gradient in my part of town. I live within spitting distance of the lake and want to demonstrate the lake effect.

Ideally, I would make the geographical location of reading-taking as a constant (a grid of points across the area) and record the temperature value at that point. i.e. coordinates are fixed, reading is variable.

This isn't practical, so what I'm doing instead is making the temperature readings fixed (every one degree change) and letting the coordinates vary, plotting the location on a map.

What I'm doing then is normalizing the data. I don't care about the actual temperature , only the change in temperature. I set my house as 0, and normalize all readings from there (+1,+2,+3, etc.)

Questions:
1] Say this is my data set for one stretch of road over several days: (+1,+2,+2,+2,+7). So, four of the days this stretch of road is about 1-2 degrees higher than at my house, but one day it was 7 degreees higher. Do I want to take the average(+2.8), or the mean (+2)? Seems to me I want the mean.

2] I'm not sure how I will determine from the data where the contour lines will be drawn. Any point I pick will have only a small portion of readings near it, while the rest I guess I'll have to interpolate?

Example: say this is the data on one stretch of road over three days:
Code (Text):

day 1:  +1        +2       +3  +2
day 2:  +1 +2  +3     +4
day 3:  +2        +3                             +4
Arbitrary data point: ^

day 1 interpolated temp: +2.3
day 2 interpolated temp: +4
day 3 interpolated temp: +3.1

Is that right way to go about it?

Then, if I take the mean, my temp at this point will be 3.1.
Hm. But 3.1 is not where I'll be drawing my contour is it? So now I have to move a little bit left.

I guess what I want is the other way around. Where, on those three lines (which could be considered slopes?) is the mean going to be 3?

I guess I might end up plotting these on an intermediate graph (x axis=horizontal distance, y axis = temperature). I'd figure out where the middle line (the mean) crosses y=3, and drop that to the x-axis to deterrmone where my contour goes on the road.

2. Sep 9, 2007

### AlephZero

Q1: You might consider using the median instead of the mean. If you have a fairly small number of observations and you don't know much about underlying staticstics of the situation, it's a more robust way of ignoring a few rogue data items than calculating the mean. You might want to consider ignoring ALL the data from a "rogue day" (e.g. if there was an unusual wind pattern, a local storm, or whatever) rather than ignoring different rogue temperatures at each measurement point separately.

Q2: There are two ways (at least) that you could go.

One way is to take your randomly spaced points and interpolate onto a regular grid of points, then draw contours from the regular grid. You might try the "contour" and "d3grid" options in gnuplot. The "best" way of doing the interpolation is usually problem dependent.

Another way is to define an irregular grid using your data points and work direct from that. A simple way is to split up the plane into triangles with your grid points as the vertices. Then use linear interpolation along the sides of the triangles to find the points on the contour line you want to draw. If you have a fairly small number of points (e.g. 20) this is fairly easy to do by hand. You can probably get away with interpolating "by eye" rather than calculating - you will probably finish up drawing smooth looking contours rather than doing something mathematically rigorous.

The choice of how to draw the triangles might seem arbitrary, but there is a way to define a unique triangulation (apart from a few degenerate cases) which has some "interesting" properties - google for Delaunay Triangulation. As a rule of thumb you will get somewhere close to a Delaunay Triangulation "by eye" if you aim for equilateral triangles, and avoid triangles with angles close to 180 degrees. (Triangles with one angle close to 0 and the two angles close to 90 degrees are OK, and are often needed.) One property of a D.T. is that if you draw the circumcircle of any triangle, there are no other vertices inside the circle (there may be more vertices on the circumference of the circle, in degnerate cases). Again, for a small set of points you can pretty much judge that "by eye" rather than by accurate drawing.

3. Sep 9, 2007

### DaveC426913

Oops. Median. That's the one I meant, yes. The median doesn't give rogue numbers an unfair bias.

4. Sep 9, 2007

### DaveC426913

I'm not sure how I would do this. If I have, say 6 data points in each of five data sets(days) would I do one set of triangles for each day? Or do I simply flatten all the data to 2D (discarding the "time dimension")?

Attached is a portion of my data for 4 days (by colour) of sampling.

The ground zero is in the lower left. All datasets are normalized with GZ at zero. I would drive along the roads and every time the temp changed by one degree I would plot it.

So, would I draw these triangles independent of the day parameter?

(One thing I think I'll do to improve my data collection is take only data from hot sunny days. Cool days and night readings will surely have very different results and will simply mess up the study.)

File size:
15.3 KB
Views:
58
5. Sep 9, 2007

### AlephZero

Ah!!! Sorry, I didn't understand your diagram in your first post. I thought you were measuring the temps at fixed positions each day (and then of course you would draw triangles based those fixed positions).

Your 2nd attachemnt is still waiting for approval but I understand the data in your first example now.

You could record the temp every mile (or whatever) not every time the temp changes, and get a fixed set of measurement points that way.

With your measurement method I guess you would have to use the "interpolation onto a regular grid of points" method. I don't know exactly what gnuplot does, but I've used similar software (not public domain) that does a localized least squares fitting process. At every point on the grid, the nearest data poitns were given more weight than the distant ones (in fact points further away than some user defined threshold distance could be ignored completely). In that case, you can just throw in all your data points (excluding any rogue ones) and let the least squares fit average them out for you.

6. Sep 9, 2007

### DaveC426913

Well, implicit in the fact that I make a record every time the temp changes is the fact that I also have a record at every point in between - i.e. 'same temp', 'still same', 'still same', etc.

I think that I would prefer to do it by hand.

7. Sep 10, 2007

### AlephZero

True. So record your measurements whichever way you want. Then interpolate each day's data to a set of fixed points along the (curved) length of each road - that's trivial to do to the accuracy that you took the measurements, e.g. the nearest degree.

Take the median temp at each fixed point.

Then plot the fixed points on a map for all the roads, and make the grid of triangles to interpolate between temperatures in between the roads.

8. Sep 10, 2007

### DaveC426913

Oh I see where the triangles come in now. They're simply lines between two adjacent data points (along which you can interpolate data) whose accumulation will incidentally always form triangles.

9. Sep 10, 2007

### AlephZero

The triangles are a bit more signifncant than just "incidental".

What you are really doing is interpolating your data points to form a continuous temperature function over the whole plane, and the function is made from a set of planar triangular facets. If you drew "intersecting" lines between the points, so you didn't divde the plane into triangles, you could hit problems when interpolating along the lines gave contradictory data.

For example consider 4 points in a square with temps (working round the corners in sequence) +2, -1, +4, -3. You can divide the square into triangles two ways, depending which diagonal you draw. One way gives the temp in the middle of the square as (2+4)/2 = 3. The other way gives it as (-1-3)/2 = -1. the contours you draw will be different depending which diagonal you pick.

Of course that's a contrived example, where there are not enough data points to define the contour lines properly, but the point of it is that choosing a triangulation first (independent of the temperature values) does give a unique answer, even if it's not the "right" answer.

If you were plotting contours using a computer, triangulation guarantees you don't get nonsense like contour lines that overlap, or just stop in the middle of nowhere. If you are drawing by hand you can deal with these problems any way you want, of course.

10. Sep 10, 2007

### DaveC426913

Yes, that's what I meant. You need to have triangles, but it's not the triangles per se that are important so much as that it eliminates the intersecting lines that you could get with any other polygon. Same principle with triangular facets in 3D computer modeling - but you know that already. :)