Creating a Movie with Data from Outer Space in R

July 2, 2019
By

(This article was first published on R-Bloggers – Learning Machines, and kindly contributed to R-bloggers)

Source: Wikimedia

The Rosetta mission of the European Space Agency (ESA) is one of the greatest (yet underappreciated) triumphs of humankind: it was launched in 2004 and landed the spacecraft Philae ten years later on a small comet, named 67P/Churyumov–Gerasimenko (for the whole timeline of the mission see here: Timeline of Rosetta spacecraft).

ESA provided the world with datasets of the comet which we will use to create an animated gif in R… so read on!

The only prerequisites that we need is the rgl package (on CRAN) and an installed version of ImageMagick: http://www.imagemagick.org/script/download.php.

The script itself is very short due to the powerful functions of the rgl package, the dataset is loaded directly from the internet site of ESA:

library(rgl)
comet <- readOBJ(url("http://sci.esa.int/science-e/www/object/doc.cfm?fobjectid=54726")) # may take some time to load

open3d()
## wgl 
##   1

rgl.bg(color = c("black"))
shade3d(comet, col = ("gray"))
movie3d(spin3d(axis = c(0, 0, 1)), duration = 12, dir = getwd())
## Writing 'movie000.png'
## Writing 'movie001.png'
## Writing 'movie002.png'
## Writing 'movie003.png'
[...]
## Writing 'movie118.png'
## Writing 'movie119.png'
## Writing 'movie120.png'
## Loading required namespace: magick

system("cmd.exe", input = paste("cd", getwd(), "&& convert -loop 0 movie.gif philae.gif")) # change GIF animation cycles to inf
Microsoft Windows [Version 10.0.17134.706]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Holger\[...]>cd C:/Users/Holger/[...] && convert -loop 0 movie.gif philae.gif

C:\Users\Holger\[...]>

The result is quite impressive:

I also used the dataset to create a 3D printout which is now on my desk in the office at my university:

What a symbol of the power of science to have a 3D printout of a cosmic roamer on your desk and an animated image of it on your computer!

To leave a comment for the author, please follow the link and comment on their blog: R-Bloggers – Learning Machines.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

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)