Click here to Skip to main content
6,595,854 members and growing! (18,851 online)
Email Password   helpLost your password?
Multimedia » General Graphics » General     Beginner License: The Code Project Open License (CPOL)

Create temperature maps with 2D Voronoi diagrams

By Maxim_Barsuk

A practicle application of 2D Voronoi diagrams.
C# (C# 2.0, C# 3.0), Windows (WinXP), .NET (.NET 2.0, .NET 3.0, .NET 3.5), Win32, Visual Studio (VS2008), GDI+, Dev
Posted:20 Nov 2008
Views:10,659
Bookmarked:18 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
8 votes for this article.
Popularity: 3.89 Rating: 4.31 out of 5

1
1 vote, 12.5%
2

3
2 votes, 25.0%
4
5 votes, 62.5%
5

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


Member
Hello! My name is Maxim Subbotin. I'm from Russia.
Occupation: Software Developer
Company: EPAM
Location: Russian Federation Russian Federation

Other popular General Graphics articles:

  • A flexible charting library for .NET
    Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
  • CxImage
    CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
  • 3D Pie Chart
    A class library for drawing 3D pie charts.
  • Barcode Image Generation Library
    This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data.
  • ImageStone
    An article on a library for image manipulation.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
Generalpls help Pinmemberdaskan0:35 8 Aug '09  
Generalimplementation in SharMap Pinmemberagelospanagiotakis4:23 15 Feb '09  
GeneralRe: implementation in SharMap PinmemberMaxim_Barsuk22:49 15 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis3:04 16 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis3:09 16 Feb '09  
GeneralRe: implementation in SharMap PinmemberMaxim_Barsuk23:35 16 Feb '09  
GeneralRe: implementation in SharMap Pinmemberagelospanagiotakis13:11 6 Mar '09  
GeneralBlack areas are missing? Pinmembernnononnnon8:26 14 Dec '08  
GeneralRe: Black areas are missing? PinmemberMaxim_Barsuk19:56 16 Dec '08  
GeneralInteresting... PinmemberPaul Conrad10:47 20 Nov '08  
GeneralDate overflow Pinmemberlaserbaronen2:50 20 Nov '08  
GeneralRe: Date overflow PinmemberMaxim_Barsuk5:26 20 Nov '08  
GeneralRe: Date overflow PinmemberSkymir5:25 20 Jul '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Nov 2008
Editor: Smitha Vijayan
Copyright 2008 by Maxim_Barsuk
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project