Animated Images of Arctic Sea Ice Extent Decline

September 5, 2012
By

(This article was first published on Climate Charts & Graphs I » RClimate Script, and kindly contributed to R-bloggers)

This post shows how to download and animate a series of Arctic Sea Ice Extent images using R and the animation package.

In my previous post, I showed how to download the daily arctic sea ice extent  data and generate an animation of the time series plots. In this post I show how to animate the monthly images provided by NOAA’s Nation Snow and Ice Data Center.


###### RClimate Script: NSIDC_Monthly_Sea_Ice_Extent_Images.R
## Download and process 1981 to 2012 Monthly Arctic SIE Images
## Sept. 5, 2012: https://chartsgraphs.wordpress.com; DK O'Day
##############################################################
  library(animation)
## Establish work dir to place downloaded images and gif file
  setwd(getwd())
  where <- getwd()

## Monthly NSIDC Extent Immage Link
# ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/Aug/N_198108_extn.png
  part_1 <- "ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/Aug/N_"
  part_3 <- "08_extn.png"

# Specify month number for animation
  m <- "08"

# Loop through years to create link and download images
  for (y in 1981:2012) {
     file_name <- paste(part_1, y, part_3, sep="")
     copy_name <- paste(where, "//asie",y,m,".png",sep="")
     download.file(file_name, copy_name, mode="wb")
     }

## copy last file c times to extend gif animation
    for (c in 1:2)
    {
     file_name <- paste("asie2012",c, ".png",sep="")
     file.copy(from= copy_name, to = file_name, overwrite=T)
    }

## Use animation package to generate gif file
  ani.options(convert=shQuote('C:\Program Files (x86)\ImageMagick-6.7.9-Q16\convert.exe'))
  ani.options(outdir = getwd()) # direct gif output file to working dir
  ani.options(interval= 0.70)
  im.convert("asie*.png", "asie_image_animation.gif")

 


Filed under: Arctic Sea Ice, Global Warming, RClimate Script Tagged: Arctic SeaIce, Climate Trends, R scripts

To leave a comment for the author, please follow the link and comment on his blog: Climate Charts & Graphs I » RClimate Script.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: 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.