Wind Analysis Data Visualization Application in C# with LightningChart .NET

Tutorial

A wind analysis application to measure wind speed and direction using polar charts.
Roy Liu

Omar Urbano

Software Engineer

LinkedIn icon
Wind-Analysis-Cover

Introduction

In this article, we will cover some theories on wind analysis. We will also create a simple chart to measure wind speed and direction using a polar chart. To create this chart, we will use interactive examples from the LightningChart .NET application, so I recommend that you install this application by downloading the SDK.

For more information, we will include a brief installation section for this application. You will also be able to download the project created for this article, which will allow you to review the explained code, modify it, and experiment with it. So, let’s get started!

zip icon
Download the project to follow the tutorial

Wind Analysis, Global Warming & Pollution

The study of wind behavior and other properties has always been important due to the constant climatic changes on Earth. With the help of these studies, important weather events can be predicted, which could affect various regions of our planet.

These results also assist in decision-making across various fields, such as air and maritime navigation, agriculture, livestock, tourism, etc. Climate changes have varied over the years due to global warming, and as a result, winds have been impacted, causing abrupt changes in temperature and atmospheric circulation.

Wind-Analysis-Industrial-Plant

What is the impact of global warming on the wind? 

While it is quite logical to assume that wind temperature is increasing, it is important to understand the reasons behind this behavior.

As the arctic warms faster than the tropics (Arctic amplification), fast-moving air currents in the upper atmosphere (jet streams) are weakened, causing erratic weather patterns that were not expected, such as intense heatwaves and storms during unseasonal periods.

The term “trade winds” refers to the relatively constant wind system in both hemispheres. This wind system blows from 30° latitude toward the equator, with a northeast direction in the northern hemisphere and a southeast direction in the southern hemisphere.

Trade winds blow almost constantly in the summer and less during the winter. These trade winds are severely affected by global warming, causing changes in ocean currents and the distribution of heat across the planet.

What is wind comfort? 

This is a term related to the perception of comfort with the wind in each environment. Several factors are considered, such as wind direction, temperature, humidity, and population preferences. While this concept can be quite subjective, there are measurable values we can consider, such as the wind speed.

A gentle breeze is measured between 1 and 5 meters per second, while moderate winds (18 km/h) and strong winds (36 km/h) can be uncomfortable for certain segments of the population. When the wind exceeds 54 km/h, it is considered very strong and can be dangerous in urban or exposed areas. Regarding temperature, depending on the population, a warm or cold climate may be preferred.

Wind plays a significant role in this, as a gentle breeze can feel comfortable in a mild climate, but very strong winds can alter the temperature, creating an uncomfortable environment for the development of a population.

The impact of wind analysis on air pollution

Wind analysis is important for understanding and managing air pollution, as wind patterns significantly influence the distribution, dispersion, and dilution of pollutants in the atmosphere.

By analyzing wind speed, direction, and other atmospheric conditions, it is possible to better understand how pollutants move, how long they stay in a specific area, and how they affect air quality. We can use two parameters to forecast pollutant dispersion:

Wind speed. This is the strength of the wind that directly affects the distance and speed at which pollutants disperse. In areas with strong winds, pollutants are spread over a larger area, which can reduce their concentration in a specific location and improve air quality. Weak winds lead to stagnation of pollutants, which accumulate and remain concentrated in one place, potentially causing poor air quality.

Wind direction. It determines where the pollutants are transported. If the wind blows from an industrial or polluted area toward a residential area, pollutants can be carried over long distances, affecting air quality in areas far from the original source. Conversely, if the wind blows in the opposite direction from populated or sensitive areas, it can help reduce exposure to pollutants.

Wind Engineering

Wind-Analysis-Wind-Engineering

Wind engineering is a discipline focused on understanding and managing the effects of wind on structures, the built environment, and the natural environment. It combines knowledge from civil engineering, mechanical engineering, architecture, meteorology, and fluid dynamics to design infrastructures that can withstand wind forces and improve aspects such as comfort and air quality.

Main areas of wind engineering:

  • Wind load on structures: This analyzes how wind affects the stability of buildings, bridges, and other infrastructures. Wind forces are calculated, and structural elements are designed to withstand them, considering factors such as the shape and height of buildings.
  • Aerodynamics and airflow around buildings: This studies how wind interacts with buildings, and wind tunnel tests and computer simulations (CFD) are conducted to predict wind effects and improve design.
  • Wind-induced vibrations and human comfort: This evaluates vibrations caused by wind, especially in tall buildings, and designs structures that minimize these effects.
  • Environmental impact: Wind influences the dispersion of atmospheric pollutants. Wind engineering helps manage the movement of pollution, improving air quality in urban areas.
  • Resistance to extreme weather phenomena: In areas prone to hurricanes, tornadoes, or storms, wind engineering designs structures capable of withstanding extremely strong winds. It also contributes to climate change adaptation.
  • Wind energy: This is also related to the design and optimization of wind turbines (wind generators) to harness wind as a renewable energy source.

What are computational fluid dynamics?

Computational Fluid Dynamics (CFD) is a branch of fluid mechanics that uses numerical methods and algorithms to simulate and analyze the behavior of fluids (liquids and gases) under various conditions. Through computer simulations, air, water, oil, and other fluid flows can be studied without the need for expensive physical experiments.

What is wind loading?

Wind load refers to the forces that the wind exerts on structures such as buildings, bridges, and towers. These forces are crucial for the design and safety of infrastructures, as they can affect their stability. The pressure exerted by the wind on the surface depends on the wind speed, air density, and the shape of the structure.

Types of wind loads:

  • Static wind load: This is the constant force that the wind exerts at any given moment.
  • Dynamic wind load: This considers variations in the wind, such as gusts and turbulence.

Local Setup

For this project, we need to consider the following requirements to compile the project.

  1. OS: 32-bit or 64-bit Windows Vista or later, Windows Server 2008 R2 or later.
  2. DirectX: 9.0c (Shader model 3 and higher) or 11.0 compatible graphics adapter.
  3. Visual Studio: 2022 for development, not required for deployment.
  4. Platform .NET Framework: installed version 8.0 or newer.

Now go to the next URL and download LightningChart .NET. You’ll then be redirected to a sign-in form where you’ll have to complete a simple sign-up process to get access to your LightningChart account.

Example-LightningChart-Account

After signing in to your account, you can download the SDK “free trial” version that allows you to use important features for these tables in the WPF tutorial. When you download the SDK, you’ll have a .exe file like this:

LightningChart-exe-installation

The installation will be a typical Windows process, so please continue with it until it is finished. After the installation, you will see the following programs:

LightningChart-.NET-Installed-Programs

License Manager

In this application, you will see the purchase options. All the projects that you will create with this trial SDK will be available for future developments with all features enabled.

Purchase-Options-LightningChart-.NET

XAML Code Review

To create a user interface, we can use XAML, which serves as the front end for our WPF application. XAML is quite easy to work with, like HTML, as we can use tags with properties or styles that enhance our graphical interface.

WPF provides us with a toolbox from which we can drag and position various user controls. Our interface will feature a Grid object, which will display our chart once it is configured and generated.

<!-- Main content area (left side) -->
<Grid Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,113,0">
    <!-- Your main content (e.g., a chart or other controls) goes here -->
</Grid>

We will also have a panel where we will place a selector that allows us to choose the type of dataset, whether it’s wind direction or wind speed.

<!-- Right panel with ComboBox and Slider -->
<StackPanel Grid.Column="1" Background="#F0F0F0" Margin="0,0,0,0">
    <!-- ComboBox for selecting an item -->
    <ComboBox Name="ComboBoxSelection" Margin="0,0,0,20">
        <ComboBoxItem Content="Wind Direction" IsSelected="True"/>
        <ComboBoxItem Content="Wind Speed"/>
    </ComboBox>

    <!-- Slider for selecting a number from 0 to 50531 -->
    <Slider Name="NumberSlider" Minimum="0" Maximum="50530" Value="0" TickFrequency="1" IsSnapToTickEnabled="True" ValueChanged="NumberSlider_ValueChanged" />

    <!-- TextBox for displaying the slider value, binding to the Slider's value -->
    <TextBox Name="SliderValueTextBox" Margin="0,10,0,0" 
             IsReadOnly="True" 
             Text="{Binding ElementName=NumberSlider, Path=Value, StringFormat=N0}" />

    <!-- Button to create the chart -->
    <Button Name="CreateChartButton" Content="Create Chart" Margin="0,20,0,0" Click="CreateChartButton_Click"/>
</StackPanel>

We will also have a slider, which will allow us to specify the number of data points to be processed in our chart.

Wind-Analysis-slider

Code Behind

The code for our chart is quite simple, which is one of the strengths of LC .NET. We will begin with the CreateChart() method:

// Specify the path to your JSON file
string projectDirectory = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\"));
string relativePath = $"Data\\WindData.json"; // Replace with your actual relative path
string filePath = Path.Combine(projectDirectory, relativePath);
// Read and parse the JSON file into a list of WindData objects
List<WindData> windDataList = ReadWindDataFromFile(filePath);

This method is executed at the start of our wind analysis application and must receive two parameters. The first specifies the type of dataset we want to process, and the second defines the number of data points we want to display. These values are generated by the UI controls we discussed earlier. The first step is to obtain the data from the main dataset.

To do this, we will retrieve the WindData.json file, which will be processed by the ReadWindDataFromFile method. The result will be a “WindData” list, which we can map later. If a chart has already been generated, it should be removed using the Dispose() method:

if (_chart != null)
{
    _chart.Dispose();
}

// Create a new chart.
_chart = new LightningChart
{
    ChartName = "Polar area chart"
};

//Sisable rendering, strongly recommended before updating chart properties
_chart.BeginUpdate();

//Set active view to Polar
_chart.ActiveView = ActiveView.ViewPolar;

//Create polar axis
AxisPolar axis = _chart.ViewPolar.Axes[0];
axis.MajorGrid.Visible = true;
axis.MinorGrid.Visible = true;
axis.TickMarkLocation = RoundGridTickmarkLocation.Outside;
axis.AngularReversed = true;
axis.InnerCircleRadiusPercentage = 10;
axis.MajorDivCount = 4;
axis.MinAmplitude = 0;
axis.MaxAmplitude = numberOfPoints/2;
axis.Visible = true;
axis.Title.Text = dataSet;

_chart.ViewPolar.PointLineSeries.Clear(); // Remove existing polar line series.

We create a new chart, assign its name, and begin the drawing process (BeginUpdate). The AxisPolar class will create a polar axis, where we can assign visual properties. To assign values to our polar chart, we will need the AreaPolarSeries and PolarSeriesPoint objects:

AreaSeriesPolar asp = new AreaSeriesPolar(_chart.ViewPolar, axis)
{
    FillColor = Color.FromArgb(100, Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)
};
asp.LineStyle.Color = Colors.Yellow;
asp.LineStyle.Pattern = LinePattern.Solid;
asp.LineStyle.Width = 1f;
asp.LineVisible = true;
asp.PointsVisible = false;
asp.Visible = true;

AreaPolarSeries allows us to create an object with colors, line types, and other visual properties. This class will be responsible for displaying the data points, which must be added to a PolarSeriesPoint, and this, in turn, will be added to the AreaPolarSeries.

int pointCounter = numberOfPoints;
PolarSeriesPoint[] seriesPoints = new PolarSeriesPoint[pointCounter];

double point;
for (int i = 0; i < pointCounter; i++)
{
    if (dataSet == "Wind Direction")
    {
        point = windDataList[i].WindDirection;
    }
    else
    {
        point = windDataList[i].WindSpeed;
    }

    if (point < 0)
    {
        point = 0;
    }

    seriesPoints[i].Amplitude = point;
    seriesPoints[i].Angle = i;
}
asp.Points = seriesPoints;

Finally, we add AreaPolarSeries to our chart of type AreaSeriesPolar and complete the rendering update:

//Add series to view
_chart.ViewPolar.AreaSeries.Add(asp);

//Allow chart rendering
_chart.EndUpdate();

(Content as Grid).Children.Add(_chart);

The _chart object will contain our generated wind analysis chart and will only need to be added to the XAML “grid” object.

Conclusion

Before starting to work on this wind analysis article, I hadn’t thought much about the importance of wind engineering and wind studies. The first thing that came to mind was climatology, but as I researched more, I found the various studies focused on wind behavior.

These wind analysis analyses allow us to build structures capable of withstanding changes in wind behavior and even influence the comfort of a population in a specific area. Wind energy is also extremely important today, and understanding wind behavior in a region helps predict the performance of wind turbines.

When I thought about the C# wind analysis project for this article, I envisioned a small device that would display the wind speed and direction within a circle. Something very similar to a radar, which sounds quite interesting, don’t you think?

Once again, LC .NET provides a very simple and optimized implementation. The dataset is a JSON file, but we could easily implement a component with a wind speed sensor that generates a flat file, which could serve as the data source for our chart. An interesting project to create.

I hope this wind analysis article helps you get started with a similar project. Remember, LC .NET can process millions of data points, so it will certainly not limit you when it comes to constantly reading wind data or other environmental parameters. Bye!

Continue learning with LightningChart

Quasar JS

Quasar JS

Written by a human | Updated on April 9th, 2025What is Quasar JS?  Hello! In this article, we will create a basic application using the Quasar JS framework. In this application, we will load three charts from the LC JS Library. But before we start, it would be...

Best JavaScript Charting Libraries

Best JavaScript Charting Libraries

Written by a human | Updated on April 9th, 2025Reviewing 5 of the most popular JS charting libraries  In all my previous articles I have been working with LightningChart for JS and .NET. However, in my experience, I have worked with other libraries related to...

Understanding Multithread Application with LightningChart .NET

Understanding Multithread Application with LightningChart .NET

Written by a human | Updated on April 9th, 2025Multithreaded chart applications with LightningChart .NET data visualization control  Getting an application to run smoothly using background threads can really make a big difference. Unloading non-essential...