Click here to Skip to main content
Click here to Skip to main content

Create temperature maps with 2D Voronoi diagrams

By , 20 Nov 2008
 

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.

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)

About the Author

Maxim_Barsuk
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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalimplementation in SharMapmemberagelospanagiotakis15-Feb-09 3:23 
Hi great code!
I am trying to change your algorithm to fit the needs of SharMap.geometries.point.
Sharpamap is a GIS .net .
http://sharpmap.codeplex.com/[^]
 
As you can imagine I am having some difficulties.
 
any ideas on the steps i should take on converting the data structures to fit my needs?
I can always upload a demo of my work.
GeneralRe: implementation in SharMapmemberMaxim_Barsuk15-Feb-09 21:49 
Hello! SharpMap is very interesting project for me. Please send me detailed description of your problem, I will try to help you. Thanks!
GeneralRe: implementation in SharMapmemberagelospanagiotakis16-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 SharMapmemberagelospanagiotakis16-Feb-09 2:09 
Oh I forgot to thank you for this article. I intend to use a color theme in the produced polygons too!
 
You might also want to donwload my demo application with sharpmap and advice me accordingly :
http://147.102.85.132/testsForVoronoi.rar
[^]
GeneralRe: implementation in SharMapmemberMaxim_Barsuk16-Feb-09 22:35 
Hello! I look your application as soon as possible (I have a lot of hard work today and tomorrow). Is your problem very critical? What is deadline for this solution?
GeneralRe: implementation in SharMapmemberagelospanagiotakis6-Mar-09 12:11 
hi ! i finaly did it using sharpmap and the Emgu CV (openCV a cross platform .Net wrapper to the Intel OpenCV image-processing library).
You can download the demo here: http://energy.chemeng.ntua.gr/openCV_Sharpmap_Voronoi_Delauny.rar
You can see the entire conversation
http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=18994[^]
 
I am now off to do the inverse distance interpolation method. :(

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130619.1 | Last Updated 20 Nov 2008
Article Copyright 2008 by Maxim_Barsuk
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid