The maps package in R is great for producing simple maps of data and coding up our earthquake map is pretty straightforward. Here’s the code.
From there you can simply set the image to your desktop wallpaper as you would any other image. With a little extra work, however, you can setup you Mac to run the R script and update the map each day with the most recent earthquakes. The first step is to create a shell command file in your favorite text editor and save the file with a name like “worldeq.command”.
There’s only three lines of code: The first line runs the R script to generate the global map of earthquakes. The second line of code sets the desktop background to the new image. The third line, killall Dock, refreshes the Dock to display the most recent image.
There you have it. Run the shell command anytime you’d like to update the desktop, add it to your login items to refresh the map each time you log in, or set up a cron task to update the image on an hourly basis.
To setup a cron task to refresh the map every four hours do the following (Thanks to Jason Mulcahy for help with this part):
- In terminal bring up the crontab file in the Vim editor by typing: sudo crontab -e
- Enter you password.
- Type i to modify the file. You should see –INSERT– at the bottom of the terminal. Enter everything below in line 4, making sure to correct the file path.
- * */4 * * * /Path/To/The/File/worldeq.command
- Type :w to write the above line of text to the file.
- Type :q to quit the editor.
- Verify that the changes were made by typing: sudo crontab -l