Click here to Skip to main content
15,887,341 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi there...

I have a number of data points in the form of (latitude,longitude,temperature). I am required to render the temperature on a map.

The final result should be similar to the the map here http://peseta.jrc.ec.europa.eu/peseta1_ClimateModel.html[^]


I used google heat maps for this, and was able to render the data points successfully. The problem however is that the readings are far apart, so each reading appear as a disconnected circle. I could increase the radius of the rendered data points to solve this.

My question is: Is google heat map used to render the temperature correctly? or should I use another api?


Any advice is highly appreciated.
Posted

1 solution

I found out how to calculate the interpolated temperature data points that need to be rendered. The code is very simple really:

VB
Public Structure PointXYZ
    Public X As Single
    Public Y As Single
    Public Z As Single
End Structure

Public Function GetZInterpolationForPoint(ByVal X As Single, ByVal Y As Single, ByVal KnownPoints() As PointXYZ, ByVal P As Single) As PointXYZ
    Dim I As Integer

    Dim Sum1 As Single = 0
    Dim Sum2 As Single = 0
    For I = 0 To KnownPoints.Length - 1
        Dim DX As Single = (KnownPoints(I).X - X) ^ 2
        Dim DY As Single = (KnownPoints(I).Y - Y) ^ 2
        Dim LP As Single = (DX + DY) ^ (0.5)
        Sum1 = Sum1 + KnownPoints(I).Z / (LP ^ P)
        Sum2 = Sum2 + (1.0 / (LP ^ P))
    Next

    Dim PT As New PointXYZ
    PT.X = X
    PT.Y = Y
    PT.Z = Sum1 / Sum2
    Return PT
End Function


You just call the function passing an array of PointXYZ which holds the known data points, the desired x,y value, and you get in return a PointXYZ structure containing the interpolated value.


Google heatmap however did not render the interpolated values correctly. I am wondering if there is a way to render these existing data points on top of google maps.
 
Share this answer
 
v2
Comments
Nelek 5-Nov-13 11:27am    
If you find out how to do it, would be nice if you edit your answer and explain you did it. It may help other people having similar problems in the future.
mkaatr2 5-Nov-13 11:35am    
I just posted the code. Have a wonderful day. :)
Nelek 5-Nov-13 11:47am    
Thank you, have a nice day too :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900