Visualising Climate Data with Visionary Render

Dave Corlett
Technical Consultant

Welcome to 2021! Like many people I try to come up with ways to make this year better than last year. You might be thinking it won’t take much to make 2021 better than 2020, but given it’s still January I’m feeling optimistic I can aim a little higher. One of the things I’d like to keep on doing this year is travelling less and keeping my carbon footprint down, which leads me nicely on to our topic for today: visualising climate data with Visionary Render.

I chose climate data for a few reasons: the first is that it’s something I’m personally interested in; and the second is that there’s a vast amount of climate data available for public use; and the third is it’s relatively easy to come up geometry for the visuals (a sphere is a good enough approximation). You could apply this to your own datasets, either as a relatively abstract visualisation of the data like I’ve done, or as an overlay to your existing Visionary Render scenes or CAD geometry.


For this demo I’ve built a custom version of the default sphere share which has the same resolution of my source data (2.5 degrees). This actually isn’t that difficult to do with a script, because VisRen allows you to create geometry from raw coordinates, so I just looped through the longitudes from 0° to 360° and the latitudes from -90° to +90° in 2.5 degree increments and for every combination created a 2.5°x2.5° square consisting of two triangles using the corresponding points on a unit sphere. Note that in order to set a different material on each of these squares they have to be in their own GeoGroup. Here’s a picture of the end result (wireframe and regular) with some different colours applied:

The colours used in the image above are taken at random from a VisRen version of the Magma colourmap. Magma was created for use with the Python library Matplotlib, you can find the source code for it on GitHub. I've packaged up the exact materials used here in a VRCollection which you can download from the Virtalis GitHub. This consists of 256 different materials ranging from a very dark purple to a bright pale yellow. These colours will then be used to represent different values in the dataset where dark purple is the lowest value and pale yellow is the highest.

To give the data some context I’ve reused an Earth-in-space scene that we’ve used for other demos in the past, you can see it in action here:

The Data

Now onto the fun bit. I’ve used data from the NCEP/NCAR Reanalysis dataset, specifically the monthly average temperatures from 1948 to the present day. Downloading the data is easy, the more interesting question is how to get it into VisRen? There’s a multitude of ways: I could just get all the data out of the file and stick it into a hard-coded Lua table; or put it into a simple format like CSV or JSON that I could read from a Lua script when the scene starts up.

But let’s think about it a bit more, what if this data is changing regularly? Do I want to go through that process of converting it every time just so I can visualise it in VisRen? What if it’s stored elsewhere and I can’t easily download and run some script to do that? What if this is a poorly veiled attempt at justifying something I wanted to do anyway? That’s right, I’m going to set up a web server to host the data, and fetch it with some REST API calls.

You might think this is overkill and you’re probably right, but there are advantages to using a server approach when extrapolated to a real-world scenario. It can provide the data to multiple users / applications, or provide different data (e.g. rainfall rather than temperature) without requiring an update to the VisRen scene. In addition to these things, I can write this particular server in Python very quickly, and make use of it’s excellent scientific libraries which can load the data in its native format.

I won’t go into the code here, there’s an explanation of sending HTTP requests from VisRen in the Programming guide already, but here’s a rough outline of how the interaction between VisRen and the server happens:

  • The server provides REST API which given one or more latitude, longitude and date returns the appropriate value from the loaded dataset
  • A Lua script builds a list of all the locations and asks the server for the data one month at a time
  • The resulting temperature data is mapped to a material from the magma based on a preset maximum and minimum temperature

The Result

Here’s a recording of the result:

Cool right? Well cool at the poles and in the mountains anyway. Hopefully this was an interesting example of VisRen doing something a little different. I’d love to hear your ideas for how you could create a visualisation like this with some of your own data.

Visualising Climate Data with Visionary Render

This post was certified by Virtalis on Jun 22, 2021 and last updated on Dec 03, 2021

Review: This article is well-researched and provides valuable information.