How can I determine the contour lines for temperature readings on a map?

Click For Summary

Discussion Overview

The discussion revolves around methods for determining contour lines for temperature readings on a map, focusing on the temperature gradient in a specific area influenced by local geography, such as proximity to a lake. Participants explore data normalization, interpolation techniques, and statistical measures for analyzing temperature data collected over several days.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant proposes normalizing temperature readings with their house as a baseline, raising questions about whether to use the average or mean for data analysis.
  • Another suggests considering the median instead of the mean to mitigate the influence of outlier temperatures, especially with a small dataset.
  • Participants discuss two main methods for contouring: interpolating onto a regular grid or defining an irregular grid using triangulation of data points.
  • One participant questions whether to create separate triangulations for each day's data or to flatten the data into a two-dimensional representation.
  • There is a suggestion to improve data collection by focusing on consistent weather conditions, such as only recording data on sunny days.
  • Another participant clarifies the misunderstanding regarding the method of data collection, emphasizing that recording occurs at every temperature change implies continuous data points in between.
  • Discussion includes the use of software tools like gnuplot for interpolation and localized least squares fitting to analyze temperature data.

Areas of Agreement / Disagreement

Participants express multiple competing views on the best statistical measures to use and the most effective methods for interpolation and contouring. The discussion remains unresolved regarding the optimal approach to triangulation and data representation.

Contextual Notes

Limitations include the dependence on the chosen statistical method (mean vs. median), the potential impact of outlier data, and the challenge of integrating time as a variable in the analysis. The discussion also highlights the need for careful consideration of data collection methods and conditions.

DaveC426913
Gold Member
2025 Award
Messages
24,467
Reaction score
8,726
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:
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.

Advice?
 
Physics news on Phys.org
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.
 
AlephZero said:
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.
Oops. Median. That's the one I meant, yes. The median doesn't give rogue numbers an unfair bias.
 
AlephZero said:
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.
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.)
 

Attachments

  • PF_temperature_map.jpg
    PF_temperature_map.jpg
    13.8 KB · Views: 483
DaveC426913 said:
I would drive along the roads and every time the temp changed by one degree I would plot it.

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.
 
AlephZero said:
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.
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.

AlephZero said:
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.

I think that I would prefer to do it by hand.
 
DaveC426913 said:
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.

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.
 
AlephZero said:
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.
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.
 
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
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. :)
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 2 ·
Replies
2
Views
16K
Replies
14
Views
2K
  • · Replies 66 ·
3
Replies
66
Views
8K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
0
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 45 ·
2
Replies
45
Views
6K