For my research on the effect of power outages on fertility , we study a period of extensive power rationing that lasted for almost a whole year and affected most of Latin America, but in particular, it affected Colombia. The key difficult was to determine which areas were exposed to the power-outage and the extent to which this was the case. This is not straightforward, since there does not exist household- or even municipality level consumption data.
We simply look for abnormal variation in municipality level light-emitting intensity from 1992 to 1993.
Here is some code that generates some Raster-Maps using the package rasterVis , and uses jQuery to generate a fancy before and after comparison to highlight the year-on-year changes in light intensity of 1992 compared to 1993.
###load the raster images tif<-"F101992.v4b_web.stable_lights.avg_vis.tif" f151 = raster(tif) tif<-"F101993.v4b_web.stable_lights.avg_vis.tif" f152 = raster(tif) ##crop a smaller window to plot e = extent(-78,-72,2,8) #e = extent(-80,-78,-4.6,-2) rn= crop(f151, e) rn2= crop(f152, e) ### do a logarithmic transformation to highlight places that receive not much, but some light. rn<-log(rn+1) png("1992.png") p <- levelplot(rn, layers=1, margin=FALSE,col.regions = gray(0:100/100)) p + layer(sp.polygons(COLPOB, lwd=.25, linetype=2, col='darkgray')) dev.off() rn2<-log(rn2+1) png("1993.png") p <- levelplot(rn2, layers=1, margin=FALSE,col.regions = gray(0:100/100)) p + layer(sp.polygons(COLPOB, lwd=.25, linetype=2, col='darkgray')) dev.off()
Now with this together, you can create a fancy slider as I have seen on KFOR -- comparing satellite pictures of towns before and after a tornado went through them.
Anyways, all you need is a slider.html page that contains the code referring to the two picture sources; the code is simple:
This is how it looks -- I know the stuff is not perfectly aligned, partly because when cropping the picture I made a mistake and could not be bothered with fixing it.