I have performed a geographical analysis
library(PBSmapping); library(RgoogleMaps); library(maptools)
cases<-read.table("cases.csv")
cases.ppp<-ppp(cases@coords[,1], cases@coords[,2], unitname=c("km"))
dens.cas <- density.ppp(cases.ppp, bw)
plot(dens.cas)
yielding the following image:
I would like to overlay this on some google map tiles, and I have been able to tell R to fetch the appropriate tile, as below:
shp <- importShapefile('map.shp', projection="LL");
bb <- qbbox(lat = shp[,"Y"], lon = shp[,"X"]);
MyMap <- GetMap.bbox(bb$lonR, bb$latR, destfile = "map.jpg");
However, I can't seem to find any solutions for laying the results of the analysis over the map tile. I know it is possible to overlay the shapefile using this solution:
https://stackoverflow.com/a/2105912/1540735
This does work, and is perfectly aligned in terms of geolocation (as below), but I lose the results of the analysis:
PlotPolysOnStaticMap(MyMap, shp, lwd=.5, col = rgb(1,1,1,0.2), add = F)
Does anyone know how to overlay these? The numerical values that give rise to the colours are stored in dens.cas$v, and are stored as a 128*128 matrix, as far as I can tell.
Many thanks to anyone who can help