I'm trying to make a choropleth in R using a polygon file, with a points layer of local care homes on top. When I plot each layer individually they're fine, however when I put them both together (using spplot for the polygons and plot for the points) the coordinates not longer line up, in that various points which should be in the area are now off the map (in the sea!). Is it possible that using an spplot/plot combo would cause the problem?
I'm confident there are no errors in the original files.
library(rgdal)
library(maps)
library(maptools)
library(RColorBrewer)
setwd(....)
shape <- readOGR(".","LSOA Boundaries")
setwd(".....")
values <- read.csv("lsoamappingvalues.csv")
plotme <- merge(shape,values, by.x="LSOA11CD",by.y="LSOA")
setwd(".....")
carehomes <- read.csv("care home points.csv")
x <- carehomes$LONG
y <- carehomes$LAT
homecords <- data.frame(x=as.numeric(x),y=as.numeric(y))
coordinates(homecords) <- c('x','y')
spplot(plotme, "POP", col.regions = colorRampPalette(brewer.pal(9, "Greens"))(100), col=NA) plot(homecords, add = TRUE, col='red', pch=19)