Creating a 3D Star Map in Tableau

For some time now, I’ve been wanting to create a sort of map of the visible stars, but was never quite sure how to accomplish it. But, after experimenting with visualization in 3D, inspired by Anya A’Hearn and Phillip Riggs’s post, The 3D Full Monty, I got an idea—what if we were to map the stars in three dimensions? By simply rotating the visualization, you would be changing your perspective, allowing you to see all the stars. But, how to do it…

Note: My completed Star Map visualization has been on Tableau Public for a couple of weeks now and a few people have expressed interest in hearing how it was built, so this post will take you through my process of creating the visualization. If you’re not interested in all the details, feel free to skip to the end to see the final result.

Right Ascension and Declination
The key to creating a 3D model of the visible stars are three measures: Distance, Right Ascension, and Declination. Such a model holds the Sun in the center (at point 0,0,0). Distance, therefore, is the distance from the Sun to the star being mapped. The other two are somewhat more difficult to understand. They are, essentially, a coordinate system that defines the position of a star, as mapped to the earth’s equatorial coordinate system. I have to admit that I do not fully understand this, but if you want to learn more, I’d highly recommend the article, What Are Celestial Coordinates, from Sky and Telescopemagazine. The following image can also be helpful in understanding Right Ascension and Declination:

By Tfr000 (talk) 15:34, 15 June 2012 (UTC) – Own work, CC BY-SA 3.0,

For my purposes, however, the most important thing to know is that these “Astronomical Coordinates” can be used to calculate 3-dimensional coordinates (usually denoted by x, y, and z) for the stars. And, with these coordinates, I’d be able to visualize the stars in Tableau.

The Data
Now that I knew this could be done, I needed to find some data. It took me a while, but I eventually discovered The HYG Database, which includes almost 120,000 different stars compiled from the three most commonly used star catalogs, Hipparcos, Yale Bright Star, and Gliese. For my purposes, I wanted to focus on those stars that are visible to the naked eye, so I removed non-visible stars based on the star magnitude, which measures how bright a star appears from Earth. Stars with low magnitudes are very bright—the sun has a magnitude of -26.7—and stars with a high magnitude are dim. At around magnitude 7, stars can no longer be seen by the naked eye, so I removed those from the database, leaving me with about 15,000 stars.

The database contains just about every imaginable detail about each star. I did not need a lot of these, but a few of them would be key to my visualization. Of course, Distance, Right Ascension, Declination, and Magnitude were critical, but I also needed information about the star’s constellation, its ID in various catalogs, and its Color Index, a simple numeric expression which defines the color of the star (we’ll come back to this later).

With data in hand, I now needed to calculate my 3D coordinates. But, guess what!! The HYG database already include the coordinates for me, so calculation would not be necessary. Armed with this data, I quickly visualized the 3D star map in Tableau (I leveraged Bora Beran’s incredible tutorial, Going 3D with Tableau) and got this:

Not bad, but I wanted my audience to be able to zoom in on a constellation and see it similarly to how it looks in the night sky, so I filtered the map down to just Orion and was disappointed when I could not easily make out the familiar shape of “The Hunter”:

It didn’t take long for me to figure out the problem. As mentioned above, the coordinates are partially based on distance from the sun. So, I suspected, the constellation looked distorted because our 3D model was showing some stars at a much greater distance from the center than others. What I really wanted, however, was for the stars to appear as if they are on the same plane. Essentially, I needed to project each star onto an imaginary sphere, which would ensure that they all appear to be the same distance from us. So, about that thing I said earlier about not having to calculate the coordinates…

Thanks to a conversation on Stack Exchange, I discovered the calculations, which are as follows:

X = Distance * COS(Radians(Declination)) * COS(Radians(Right Ascension*15))
Y = Distance * COS(Radians(Declination)) * SIN(Radians(Right Ascension*15))
Z = Distance * SIN(Radians(Declination))

In my case, I wanted to make Distance a constant so that the stars would be projected onto an imaginary sphere. The actual value is largely unimportant, so I just made it 1. From there, I calculated my x, y, and z coordinates, then leveraged Bora’s calculations to convert these into a 2 dimensional coordinate system. Finally, I plotted the stars’ coordinates in Tableau and sized each star according to magnitude.

Note: As I said earlier, the sun is always in the center point. However, I've chosen to hide the sun because it appears significantly brighter in our sky and, therefore, would tend to overshadow all the other stars.

Now, when we filter down to Orion, we are able to see something more like we expect (I've added to this image in order to provide context):

Looking back, I could have just divided the HYG coordinates by Distance to remove the impact of the variable, but I didn’t think of that at the time…

But, if you know anything about astronomy, you’ll know that Betelgeuse is a very noticeable orangish red color. So, I wanted to do something adjust each star’s color to more closely match their actual color. To do this, I figured that I’d need to use the Color Index mentioned earlier. Strictly speaking, color index doesn’t directly relate to visible color as there are many things that determine how we perceive color. A star’s color index is not really about our perception but the actual makeup and temperature of the star (for a good discussion on this, check out A Hex on Star Colors). However, color index is the closest we can get to an estimate of a star’s color and should work well enough for our visualization.

After searching around for a bit, I found a few collections of code that attempt to convert Color Index to actual RGB/Hex colors. After testing a few of them out, I settled on one I found on, which was written in JavaScript. Luckily for me, my data was stored in Google Sheets, which has a scripting environment based on JavaScript. So, I copied the code and modified it to work as a function, then used it to convert all of the stars’ color indexes to RGB/ Hex. Using the list of Hex colors, I created a custom categorical color palette in Tableau, and colored the stars accordingly.

Tooltip Zoom
Tableau 10.5 just introduced the Viz in Tooltip feature and, even though I was pretty much done with this viz at the time, I thought it could be of value. Specifically, I thought it would be neat to be able to hover over a start and get a sort of zoomed image of the star in order to get a better feel for both its relative size and its color. So, hovering over a star, such as Betelgeuse, will show you this:

Finishing Touches
With all the hard work complete, I put the visualization on a dashboard, added parameters for rotating in all three dimensions (all included in Bora’s tutorial), added a filter and highlighter for constellation, and generally just prettied it up. I’m quite happy with the results. Click on the image below to see the fully interactive version:

If you have any thoughts or questions, I’d love to hear about them in the comments section below.

Ken Flerlage, January 20, 2018


  1. this is simply awesome!

  2. Hi Ken, I'm returning to your post since I'm referencing your work on my Nasa Space Apps Hackathon's challenge. I'm having a hard time trying to convert a 3D sphere stl file into tde reconizable Tableau format. Would you share where you got the sphere and how you handled the conversion?

    1. There is actually no stl file involved in this. I downloaded the HYG Database, which has Declination and Right Ascension then used those to calculate the X, Y, and Z coordinates.


Powered by Blogger.