Planet snaps is a twitter bot which takes imagery from http://earth.nullschool.net and combines them into animated .gifs. The bot is a python script which chooses a field of the several available, randomly selects a location (latitude, longitude), and then constructs a timelapse every few hours. Other than a few restrictions to prevent boring animations (no zoomed in views of pollution over Antarctica, for example) I have no control over what the bot chooses to show.
For more information about the data used in the visualisations, as well as full explanations of the fields depicted, please see https://earth.nullschool.net/about.html. And have a play on the website yourself - it’s one of the best things on the internet, and completely free to use!
To briefly describe how the bot works, after a location and field are selected the script creates a chrome window. The http://earth.nullschool.net interface allows the location, field, and time of data shown to be specified in the URL, e.g. https://earth.nullschool.net/#2019/01/09/0300Z/wind/surface/level/overlay=temp/orthographic=-1.09,51.86,339 shows the surface temperature centred at (51.86,-1.09) at 3AM on 2019/1/9. The bot script loads the URL for the field of interest two weeks (the default length of timelapse) prior to the current date at the location of interest. It then takes a screenshot of the chrome window, and saves it. It then loads the same field at the same location 3 hours later and takes another screenshot. It keeps doing this until the URL asking for the field at the current date and time is reached. The script then closes the chrome window, does a little image processing, and combines all the screenshots into a .gif.
Depending on how complex the motion is in the .gif, the quality varies in order to fit under the 5MB required by twitter’s API (different from the 15MB limit for web users). This results in some very nice looking .gifs when the fields aren’t terribly complex, and some very janky .gifs when the fields are!
Future work on the bot:
Subject to interest in the project, adding stills of fields over interesting locations (randomly chosen) several times a day
Subject to interest, uploading the code to github
Automate posting to linked Instagram account
.gif optimisation is achieved with the —lossy keyword of gifsicle (using the giflossy fork of the library) along with reducing the dimensions of the frames used. This produces some results which are less than perfect, and I’d like to represent complex fields in particular with less compression. Suggestions for how best to do this are welcome!