Aug 26 2009
Am I Really Going There? Rose Diagrams with Google Chart and Python
So, now that everyone knows that it’s dead easy to calculate the average azimuth, we’ll all be doing it, right?. There’ll be a rash of Silicon Valley start-ups all generating social networking applications where we all show off our general direction so that we can see if we’re headed in the direction of our friends. But that’s not enough for me. I want to visualize the data. I want at least a modicum of verification, not just a swallow of the Kool-Aid.
What I wanted to do was quickly generate a rose diagram, also known as a circular histogram. It’s basically a picture of the number of values for each of a range of values. Here’s an example showing wind direction. The relative size of each of the blue sections is determined by the magnitude of the value recorded within that 10° range.
The chart basically gives you a visual representation of all the data of an angular dataset, while letting you also see qualitatively the general tendency of the data. This would be useful to me in my azimuth data because I’d like to know how many values I have in each range, as a way to determine whether my average calculation was meaningful.
Google Chart
Google’s chart API provides a really fast way to programatically create charts, and I’ve been using it a lot lately. Unfortunately, the API doesn’t include the functionality to create a rose diagram. The best it can do is a radar chart.
A radar chart is a multivariate visualization tool showing values of variables around a central axis. This is not really what I want, but I thought I might be able to use it to fake a rose diagram, so I dove headlong into Python and the Google-ChartWrapper library and came up with some code which yields a pseudo-rose diagram similar to this:
I call it a “pseudo-rose diagram” because it’s basically a radar chart with 36 unique values, each at 10° increments. The data points at each of these 10° illustrates the “weight” of the data in that increment.
Since a radar diagram is a continuous line around the center, I couldn’t make distinct “bins” at each increment. Rather, I just drew the line around with weights from 0 to 16.1
The green line shows the calculated average azimuth. This average is calculated using the method discussed in the previous post. The chart provides me a quick visual of the data and my average. It’s not perfect, but it’s enough to let me know, for instance, that the real average of this data might be closer to 190° than 168°, but that the calculated average is probably accurate enough unless we want to kill the outliers.
The code for this is available on Github as PyGoogleRose.2 Feel free to download it and play with it.
With this, I was able to create a Google Earth snapshot of all of my data, and include the rose diagram in the callout box as an <img /> tag with a link. The result is given below, showing a visual of datapoints across the Snake River, downstream of Lower Granite Dam.
Each datapoint is a collection of samples, and the rose diagram allows us a better visual representation of the spread of the samples and the azimuth direction.
The code on Github is pretty basic, there’s very little versatility to change the increments, weighting or anything, it’s basically a hack to quickly take care of a task. However, since it’s a class, it’d be easy to change things for your needs if, for instance, you wanted total magnitude in a direction or a different number of histogram bins.
- the Google Chart API using hexidecimal values in radar charts. [↩]
- If you’re reading this on my blog’s home, instead of a feed, a link to my current Github code is also available on the sidebar [↩]
- Where am I headed? Calculating the Average of Azimuth Values
- Am I Really Going There? Rose Diagrams with Google Chart and Python
- Wow! Fully Functional Rose Diagrams with Google Chart!
- When Is An Average Meaningful?
- Time-based Visualization With Rose Diagrams


