-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRefugeeHTML
41 lines (40 loc) · 1.33 KB
/
RefugeeHTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##Code for HTML animation of refugee settlements
##50 .png images in /dotimages directory
setwd("C:/Users/Justin/Pictures/dotimages")
files<-dir()
print(pics<-files[grep(".png",files,ignore.case=T)])
pics<-mixedsort(pics)
saveHTML({
for(i in pics){
tmp <- readPNG(i)
par(bg = "thistle",mar=c(0,0,0,0))
plot(c(0,20),c(0,60),
bty="n", xlab="", ylab="")
rasterImage(tmp, 0, 0, 20, 60)
}
},img.name="pic",interval=.2,ani.height=500,ani.width=1000,htmlfile="refugee.html",
outdire=getwd(),title="Refugee Informal Settlements")
##Code for creating .GIF file of same animation
library(animation)
library(png)
library(raster)
##Set directory to work in with images for .gif
setwd("C:/Program Files/R/R-3.1.1/dotimages")
files<-dir()
##Name character vector of .png files to be made into a .gif
pics<-files[grep(".png",files,ignore.case=T)]
##Sort numerically (if they are named numerically)##
pics<-mixedsort(pics)
##Must install ImageMagick prior to naming this path
pathc<-"C:/Program Files (x86)/ImageMagick-6.8.9-Q16/convert.exe"
saveGIF({
for(i in pics){
tmp <- readPNG(i)
par(bg = "white",mar=c(0,0,0,0))
plot(c(0,20),c(0,60),
bty="n", xlab="", ylab="")
rasterImage(tmp, 0, 0, 20, 60)
}
},movie.name="refugee1.gif",img.name="nothing"
,ani.options(pathc),interval=.4,ani.width=1200,
ani.height=500,clean=TRUE)