I follow a great example here . Everything works up to the grid graph,
library("lattice")
spplot(sp_grd, "id", colorkey=FALSE,
panel = function(...) {
panel.gridplot(..., border="black", col.regions="white")
sp.polygons(shp)
sp.points(poi, cex=1.5)
panel.text(..., col="red")
})
When I try to do this, I get an error,
'Error when using package 1 formal argument "col.regions", matched by several actual arguments.
Any ideas for fixes? Basically, I do not want the panels to fill with colors, as it is by default.
EDIT: Reproducible example modified from a link.
library("rgdal")
library("lattice")
library("rworldmap")
shp <- getMap(resolution="low")
poi <- data.frame(x=c(15, 25, 35, 100),
y=c(-15, 25, -35, -50),
id="A", stringsAsFactors=F)
coordinates(poi) <- ~ x + y
proj4string(poi) <- proj4string(shp)
bb <- bbox(shp)
cs <- c(10, 10)
cc <- bb[, 1] + (cs/2)
cd <- ceiling(diff(t(bb))/cs)
grd <- GridTopology(cellcentre.offset=cc, cellsize=cs, cells.dim=cd)
sp_grd <- SpatialGridDataFrame(grd,
data=data.frame(id=1:prod(cd)),
proj4string=CRS(proj4string(shp)))
spplot(sp_grd, "id",
panel = function(...) {
panel.gridplot(..., border="black")
sp.polygons(shp)
sp.points(poi, cex=1.5)
panel.text(...)
})
spplot(sp_grd, "id",
panel = function(...) {
panel.gridplot(..., border="black", col.regions="white")
sp.polygons(shp)
sp.points(poi, cex=1.5)
panel.text(...)
})