Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / Win32
Article

Create temperature maps with 2D Voronoi diagrams

Rate me:
Please Sign up or sign in to vote.
4.79/5 (11 votes)
20 Nov 2008CPOL1 min read 64K   1.6K   31   13
A practicle application of 2D Voronoi diagrams.

Introduction

Voronoi Diagram is a useful mathematic abstraction which has many applications. You can read about it here and here. You can also see some examples here: Visualization of the 2D Voronoi Diagram and the Delaunay Triangulation and Fortune's Voronoi algorithm implemented in C#.

Background

Yesterday, I solved a problem: we have many weather centers and each weather center has coordinates (X, Y) and current temperature value (T). The goal of our solution was to create a temperature map.

Using the code

The structure TemperatureLocation stores data about the weather center: coordinates X, Y, and the temperature value.

C#
public struct TemperatureLocation
{
    private double x;

    public double X
    {
        get { return x; }
        set { x = value; }
    }
    private double y;

    public double Y
    {
        get { return y; }
        set { y = value; }
    }
    private double t;

    public double T
    {
        get { return t; }
        set { t = value; }
    }

    public TemperatureLocation(double x, double y, double t)
    {
        this.x = x;
        this.y = y;
        this.t = t;
    }

    public double GetDistance(TemperatureLocation tl)
    {
        return Math.Sqrt((this.x - tl.x) * (this.x - tl.x) + 
                         (this.y - tl.y) * (this.y - tl.y));
    }
}

The class VoronoiTemparature is designed to create temperature maps. We load data about weather center, the parameters of the image (the color of cold and hot temperatures), and get the image of the map. For a more realistic map (without accurate Voronoi cells), use a simple smooth effect. The result of the test creation map can be seen on Figure 1.

VoronoiTemperature.JPG

Figure 1. Temperature map.

Points of interest

Creating temperature maps is really a problem in meteorology. For a good mapping, we must use interpolation algorithms (for a smooth isotherm). It is one of many Voronoi diagram applications (Voronoi died exactly 100 years ago, on 11-19-1908).

License

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


Written By
Software Developer
Russian Federation Russian Federation
Hello! My name is Maxim Subbotin.

Now I work in sphere of web-development. I'm interesting researches in SEO field.
If you interesting, you can see this tool:

KeywordCompetitor

Comments and Discussions

 
Generalpls help Pin
daskan7-Aug-09 23:35
daskan7-Aug-09 23:35 
Generalimplementation in SharMap Pin
agelospanagiotakis15-Feb-09 3:23
agelospanagiotakis15-Feb-09 3:23 
GeneralRe: implementation in SharMap Pin
Maxim_Barsuk15-Feb-09 21:49
Maxim_Barsuk15-Feb-09 21:49 
GeneralRe: implementation in SharMap Pin
agelospanagiotakis16-Feb-09 2:04
agelospanagiotakis16-Feb-09 2:04 
Hi i am trying to find the voronoi polygins for a given set of points.

Please Read the full discussion online on the sharpmap codeplex discussion forum.
http://www.codeplex.com/SharpMap/Thread/View.aspx?ThreadId=18994&ANCHOR#Post157880[^]
I am having proplems geting correct answers from this algorithm. Propably due to the datatypes used in the calculations(points/doubles).
Any help will be greatly appreciated. Thumbs Up | :thumbsup:

Best Regards,
Agelos
GeneralRe: implementation in SharMap Pin
agelospanagiotakis16-Feb-09 2:09
agelospanagiotakis16-Feb-09 2:09 
GeneralRe: implementation in SharMap Pin
Maxim_Barsuk16-Feb-09 22:35
Maxim_Barsuk16-Feb-09 22:35 
GeneralRe: implementation in SharMap Pin
agelospanagiotakis6-Mar-09 12:11
agelospanagiotakis6-Mar-09 12:11 
QuestionBlack areas are missing? Pin
nnononnnon14-Dec-08 7:26
nnononnnon14-Dec-08 7:26 
AnswerRe: Black areas are missing? Pin
Maxim_Barsuk16-Dec-08 18:56
Maxim_Barsuk16-Dec-08 18:56 
GeneralInteresting... Pin
Paul Conrad20-Nov-08 9:47
professionalPaul Conrad20-Nov-08 9:47 
GeneralDate overflow Pin
laserbaronen20-Nov-08 1:50
laserbaronen20-Nov-08 1:50 
GeneralRe: Date overflow Pin
Maxim_Barsuk20-Nov-08 4:26
Maxim_Barsuk20-Nov-08 4:26 
GeneralRe: Date overflow Pin
Skymir20-Jul-09 4:25
Skymir20-Jul-09 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.