[R-sig-Geo] [R-sig-geo]: Plot spatial data with spplot and maps

pelt pelt at knmi.nl
Thu Nov 4 14:24:46 CET 2010


Hi all,

I have made a plot with ssplot, using a SpatialPointsDataFrame. The
content is quite simple, as I have 9 grid points with lon/lat
coordinates and 9 values attached to these coordinates. They are in a
square area of 3 by 3 gridboxes.
I would like to lay a map from maps() over these values, but when I try
this, the grids of the maps  do not overlap with the grids I have
already created with spplot(). I would like shaded gridboxes, the boxes
should be filled with colour. Can anyone help me with this problem?
Thank you in advance!
This is part of my code:

lonlim <-c(4.5,12)
latlim <-c(46.5,52.5)

map(xlim=lonlim, ylim=latlim,col='white')

gt=GridTopology(cellcentre.offset=c(5.75,47.5),cellsize=c(2.5,2),cells.dim=c(3,3)) 

grd=SpatialGrid(gt,proj4string = CRS(as.character(NA)))
gridparameters(grd)
gd<-as.data.frame(grd,"SpatialGrid")
h<-season_djf  # which are 9 values
h<-as.data.frame(h)
djf.att=SpatialPointsDataFrame(gd,h)
gridded(djf.att)=TRUE

spplot(djf.att, col.regions = colorRampPalette(c("red","orange",
"yellow", "lightblue", "blue",
"purple")), xlab="Longitude(°)",
ylab="Latitude(°)",add=T,scales=list(draw=T),main="Seasonal change",
font.main=4)

map('rivers',add=T)
map('worldHires',add=T)

Regards,
Saskia van Pelt



More information about the R-sig-Geo mailing list