############# 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 working directory 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 gernerate 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")