{"word_count": 189, "character_count": 2149}
With R, it is extremely easy to draw maps. Let us start with something simple, like French regions. Baptiste mentioned on his blog that shapefiles can be downloaded from http://ign.fr/ website. Hence, if you extract the zip file, it is possible to get claims frequency per region (as done in the course ACT2040),&#62; library(maptools)&#62; library(maps)&#62; departements&#60;-readShapeSpatial("DEPARTEMENT.SHP")&#62; region&#60;-tapply(baseFREQ[,"nbre"],+ as.factor(baseFREQ[,"region"]),sum)/+ tapply(baseFREQ[,"exposition"],+ as.factor(baseFREQ[,"region"]),sum)&#62; depFREQ=rep(NA,nrow(departements))&#62; names(depFREQ)=as.character(+ departements$CODE_REG)&#62; for(nom in names(region)){+ depFREQ[names(depFREQ)==nom] =+ region[nom]}&#62; plot(departements,col=gray((depFREQ-.05)*20))&#62; legend(166963,6561753,legend=seq(1,0,by=-.1)/20+.05,+ fill=gray(seq(1,0,by=-.1)),cex=1.25, bty="n")Another application is on earthquakes. It is possible to use shapefiles of tectonic plates contour, and to relate earthquakes to plates. Shapefiles can be found onhttp://www.colorado.edu/ (here).First, we can extract the shapes of the tectonic plates&#62; plates = readShapePoly("plates.shp",+ proj4string=CRS("+proj=longlat"))&#62; PP=SpatialPolygons2PolySet(plates)Consider Montreal,&#62; montreal=c(-73.600,45.500)Given that specific location, it is possible to use the following code to get the associated plate,&#62; PLATE.loc=function(pt){+ K=NA+ for(k in 1:17){+ c=point.in.polygon(pt[1], pt[2],+ PP[PP$PID==k,c("X")],PP[PP$PID==k,c("Y")],+ mode.checked=FALSE)+ if(c&#62;0){K=k}+ }+ return(K)}&#62; abline(v=montreal[1],col="red")&#62; abline(h=montreal[2],col="red")&#62; PLATE.loc(montreal)[1] 1and then to plot the associated tectonic plate very easily&#62; PLATE=function(k0){+ library(maps)+ map("world")+ polygon(PP[PP$PID==k0,c("X")],PP[PP$PID==k0,c("Y")],+ col="red")+ for(k in (1:17)[-k0]){polygon(PP[PP$PID==k,c("X")],+ PP[PP$PID==k,c("Y")],col="light blue")}+ map("world",add=TRUE)}&#62; PLATE(PLATE.loc(montreal))Those code were used in the paper written with Mathieu, and that will be presented on January 30th at the Geotop seminar.