Animated Images of Arctic Sea Ice Extent Decline

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: http://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")

 

About these ads

One response to “Animated Images of Arctic Sea Ice Extent Decline

  1. Pingback: Animated Images of Arctic Sea Ice Extent Decline - R Project Aggregate

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s