RObservations #45: Making Beautiful Star Maps With The `starBliss` Package

[This article was first published on r – bensstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction

Continuing my explorations in developing custom map art, I decided to take a detour from developing the mapBliss package to explore another type of map which is very popular in the map-art space- star and constellation maps! This initially started out as an issue opened on the mapBliss Github. However, I quickly realized the framework required for making star maps is completely different from making regular maps for custom fight paths and road trips.

In this blog I introduce the “cousin” to the mapBliss package – starBliss! While it is still very basic I am very happy how it turned out. The starBliss package creates custom “framed” constellation maps with for a given location and date as well as allowing users to add some custom text as well.

This blog is simply a brief overview of the journey for how this package came to be. For a more technical deep dive regarding how and why this package works, I suggest that you check out Kim Fitter’s and Diego Hernangomez’s blogs on the topic.

If you want to skip straight to using the package, check out the basic usage examples on Github or skip to the code blocks here. But before getting into that, I thought I would share some background on how this package came to be.

Why starmaps are not included in mapBliss

mapBliss aims imitate the product produced by Atlas.co and similar companies which make use of leaflet. Maps produced by mapBliss are dynamic maps which need to be screenshot and converted to .svg files to be usable in a printing setting. The way maps are created with starBliss are static and use ggplot2 and are able to be saved to whatever size desired using ggsave(). Since the approaches to making visuals were so different, I thought it was best make keep the mapBliss and starBliss packages separate in their construction.

That being said, if there is a leaflet -like package for creating star maps, feel free to let me know by commenting here or opening an issue on the mapBliss or starBliss Github repositories!

Exploring Starmaps

I initially was interested in designing star maps after seeing a Facebook ad for a UK based company called MapsForMoments. The maps looked pretty, customizable and frankly easier to make than the maps that I was working on for mapBliss. All I needed to do was get my hands on stars and constellations data and plot it. Conceptually this seemed like it was easy enough, however to actually make it- I needed lots of help!

The journey started with me posting a question on the Astronomy StackOverflow community asking for a library or API that behaved like leaflet but for starmaps.

The answer I got there lead be to Kim Fitter’s blog which introduced me to the D3 Celestial maps data. From her blog I was able to replicate her visual:

While I managed to replicate what Kim did, I wanted to create maps which were similar to MapsForMoments. The problem was that I didn’t know anything about map projections. Which led me to have some email correspondence with Kim and going to StackOverflow to ask the talented folks there what to do. To my surprise I got an incredibly complete answer. Thank you Dr. Allan Cameron!

After learning how to do it, I packaged starBliss and I thought I was ready to start blogging. But before I got to it, Bernardo Lares pointed out some bugs that needed to be addressed and features that would be useful. After taking care of that and getting some more help from the folks at StackOverflow (thank you Diego Hernangomez) I managed to put out a package that is simple and straightforward to use for making custom souvenir star maps!

Using the package

With the help of getting user feedback from Bernardo and others, it is possible now make a star map with a single function and a single argument.

Suppose we want to get a star map of Seoul, South Korea at the time of writing this blog (February 12, 2023) which is fully labelled. To do this all we need is:

#devtools::install_packages("starBliss")

library(starBliss)

plot_starmap("Seoul, South Korea")

Right now there are two styles: “black” – which was just shown and “green”, which can be selected by specifying the “style” argument:

plot_starmap("Seoul, South Korea",style="green")

If you want to change the line texts, the line1_text, line2_text and line3_text arguments can be specified accordingly.

p<- plot_starmap(location="Toronto, ON",
                 style="green",
                 line1_text = "When I first wrote this blog")

p

Now if you want to save your map in print quality form, just use the ggsave() function from ggplot2 as these visuals are all from ggplot2!

library(magrittr)
library(ggplot2)

p %>% ggsave('starBliss_blog.png', 
             plot = ., 
             width = unit(10, 'in'), 
             height = unit(15, 'in'))

And that’s pretty much it!

Conclusion

As stated in the beginning, the starBliss package is a result of a detour in the development of mapBliss. The sky’s the limit as far as other features and designs which could be added. However the package right now works as a “MVP” for quickly visualizing star maps in a artful manner.

Be sure to star the repo and open an issue if you want to see a new feature or work on adding one! I do have some ideas about making a GUI for starBliss in a designated repository but I don’t have a any sort of timeline for getting anything done.

Thank you for reading!

Want to see more of my content?

Be sure to subscribe and never miss an update!

To leave a comment for the author, please follow the link and comment on their blog: r – bensstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)