I have analysed a dataset of GPS points using density.ppp to generate a sort of heatmap of intensity of the points, as shown below:
However, I would like the image to be limited to the borders of the shapefile, similar to below:
The first image is called as
x <- readShapePoly("dk.shp")
xlim<-c(min(912),max(920))
ylim<-c(min(8023),max(8030))
a<-ppp(cases@coords[,1], cases@coords[,2], xlim, ylim, unitname=c("km"))
plot(density.ppp(a, 0.1), col=COLORS)
plot(x, add=T, border="white")
where cases@coords are the GPS coordinates of each point of interest, and x is a shapefile which provides the outline for the geographical unit.
The second image is called using this code:
plot(x, axes=T, col=COLORS, border="White")
Does anyone know how this might be done? Perhaps it's not possible with plot() and I will need another package.
As an aside, the next step I plan to do will be to overlay this image over a map imported from GoogleEarth. I'm not yet sure how to do that either, but will post the answer if and when I work it out
many thanks