# Create temperature maps with 2D Voronoi diagrams

By , 20 Nov 2008
Votes of 3 or less require a comment

## 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.

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).

Software Developer
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

 First PrevNext
 implementation in SharMap agelospanagiotakis 15-Feb-09 3:23
 Re: implementation in SharMap Maxim_Barsuk 15-Feb-09 21:49
 Re: implementation in SharMap agelospanagiotakis 16-Feb-09 2:04
 Re: implementation in SharMap agelospanagiotakis 16-Feb-09 2:09
 Re: implementation in SharMap Maxim_Barsuk 16-Feb-09 22:35
 Re: implementation in SharMap agelospanagiotakis 6-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. :(
 Black areas are missing? nnononnnon 14-Dec-08 7:26
 Re: Black areas are missing? Maxim_Barsuk 16-Dec-08 18:56