[R] spatial plots maps-ssplot

pelt pelt at knmi.nl
Tue Nov 2 13:29:43 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 (smaller) 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:

minlon<-4.5
maxlon<-12
minlat<-46.5
maxlat<-52.5

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
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 DJF 
MIUB", font.main=4)

map('rivers', xlim=c(minlon,maxlon),ylim= c(minlat,maxlat), 
col="blue",add=T)
map('worldHires', xlim = c(minlon, maxlon), ylim = c(minlat, maxlat), 
add = T, col =
"darkgrey",wrap=T)

Regards,
Saskia van Pelt



More information about the R-help mailing list