Creating gifs from Google Earth historical imagery on GNU/Linux with Bash
First, I downloaded Google Earth for Linux and installed it on my Chromebook (which is running a chroot with crouton). I then proceeded to find deforested zones in Brazil, which was not difficult. I used the history tool to go back in time.
Google Earth contains decent images from Landsat/Copernicus that goes back to 1984. This allows one to see troubling forest destruction in South America, the damages of tar sands extraction in Alberta, and many other things I did not have the time to look at yet.
I figured out it would be too long to do all the clicking and screenshots-taking by hand, so I wrote a dirty bash script to do that for me. This script uses xdotool to place the mouse and perform clicks. I hardcoded the “next year” button’s position into the script, so if you try it, you may have to change the position to match the button’s position on your screen (#cleancode). The script uses
import, an ImageMagick utility which is able to take cropped screenshots from a window and save them.
Once all the pictures are taken, I call
convert to create a gif. I tweaked the settings to make the gif small enough for publishing on the internet without slowing everyone’s tumblr. Normally, I try to keep my GLSL gifs’ size under 100K, but since the environment is important, I allowed myself to keep some image quality here and go a bit above 200K.
# Note: I have to go to year 1984 before the script starts # Sleep to let user move to other terminal tab # and monitor memory with top ;) sleep 3 echo "starting" # For every year: for i in `seq 1984 2016`; do # Print current year echo $i # Take screenshot import -window "Google Earth" -crop 500x400+500+120 $i.png # Go to next year xdotool mousemove 512 155 click 1 # Leave some time for the image to load sleep 4 done; echo "Creating anim.gif" convert *.png +repage -fuzz 20% -layers Optimize -colors 6 +dither anim.gif
Now that I have this script, I can animate whatever land that humans have destroyed since 1984, how fun! I had to reboot my Chromebook a couple of times during the development process because Google Earth was a bit exhausting for the small computer.