Hi All, I've just pinned down a problem I'm having with image(spatialGridDataFrame, breaks=*).
This relates to the recent 'colour scale' post as my rworldmap package (excuse the plug!) has options for plotting multiple world maps using the same colour scale too. The toy example below, including a workaround, should demonstrate it. I'd be grateful for any comments. Thanks, Andy library(sp) #create a 2 cell grid gt <- GridTopology( cellcentre.offset = c(0,0), cellsize = c(1,1), cells.dim = c(2,2) ) #values 1 and 2 gridVals <- data.frame(c(1,1,2,2)) sGDF <- SpatialGridDataFrame(gt, data = gridVals) #The problem #the following generates warning : "breaks" is not a graphical parameter #and the cells are coloured red and black rather than the expected red and green image(sGDF, breaks=c(0:4), col=c('red','green','blue','black')) #Workaround #this does colour the cells as expected, red & green xyz <- as.image.SpatialGridDataFrame(sGDF,attr=1) image(xyz, breaks=c(0:4),col=c('red','green','blue','black')) #This works in my rworldmap code including an add=TRUE argument #so that I can add on to a previously formatted plot window #a possibly trivial additional matter is that when I tried setting up this toy example #I initially used just 2 cells #this generates the error : 'Error in image.default ... 'z' must be a matrix' gt <- GridTopology( cellcentre.offset = c(0,0), cellsize = c(1,1), cells.dim = c(2,1) ) gridVals <- data.frame(c(1,2)) sGDF <- SpatialGridDataFrame(gt, data = gridVals) xyz <- as.image.SpatialGridDataFrame(sGDF) image(xyz, breaks=c(0:4),col=c('red','green','blue','black')) [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo