Click here to Skip to main content
Licence CPOL
First Posted 20 Nov 2008
Views 27,320
Downloads 561
Bookmarked 24 times

Create temperature maps with 2D Voronoi diagrams

By | 20 Nov 2008 | Article
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.

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

Member

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalpls help Pinmemberdaskan23:35 7 Aug '09  
Generalimplementation in SharMap Pinmemberagelospanagiotakis3:23 15 Feb '09  
GeneralRe: implementation in SharMap PinmemberMaxim_Barsuk21:49 15 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis2:04 16 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis2:09 16 Feb '09  
GeneralRe: implementation in SharMap PinmemberMaxim_Barsuk22:35 16 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis12:11 6 Mar '09  
QuestionBlack areas are missing? Pinmembernnononnnon7:26 14 Dec '08  
Hi Maxim,
 
Thanks for your efforts. This was exactly what I was looking for: a fast algorithm to atrribute a "nearest neighbour" value to each pixel of a bitmap.
The final tessel drawing in .net is very slow though. (Compare this Flash implementation: http://www.dasprinzip.com/pExamples/p70_0.html that achieves 25 fps for 100 data points.
 
My real question: shouldn't the black edges also be red? Also in the other voronoi visualization I noticed, that at the edges some lines were missing. I could accept the slow speed of .net, but not the errors.
AnswerRe: Black areas are missing? PinmemberMaxim_Barsuk18:56 16 Dec '08  
GeneralInteresting... PinmemberPaul Conrad9:47 20 Nov '08  
GeneralDate overflow Pinmemberlaserbaronen1:50 20 Nov '08  
GeneralRe: Date overflow PinmemberMaxim_Barsuk4:26 20 Nov '08  
GeneralRe: Date overflow PinmemberSkymir4:25 20 Jul '09  

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

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

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