Hi,
I would like to do coloring of map regions based on the region values
"weight". The approach I am taking is first to break regions into equal
intervals,
classIntervals(spdf$weight,4)$brks #4 intervals in this case
 and than coloring all regions within the interval with the same color
col = brewer.pal(4,"RdYlGn"))
The max "weight" is as well the boundary of the interval The problem is
that the last region is not included into the last interval nad has thus no
color. I do belive I am missing something, because any other solution to
manually manipulate the intervals, is overcomplicating the simplicity of
classIntervals function.
 any idea how to get all rectangles colored?
Thank you
Jan
here is the example, see the rectangle in the right upper corner, it
remains white.
library(sp)
library(classInt)
library(RColorBrewer)
p1=cbind(c(0,0,1,1,0),c(0,1,1,0,0));colnames(p1)=c("x","y")
p2=cbind(c(0,0,1,1,0),c(1,2,2,1,1));colnames(p2)=c("x","y")
p3=cbind(c(1,1,2,2,1),c(0,1,1,0,0));colnames(p3)=c("x","y")
p4=cbind(c(1,1,2,2,1),c(1,2,2,1,1));colnames(p4)=c("x","y")
p5=cbind(c(2,2,3,3,2),c(0,1,1,0,0));colnames(p5)=c("x","y")
p6=cbind(c(2,2,3,3,2),c(1,2,2,1,1));colnames(p6)=c("x","y")
ps1=Polygons(list(Polygon(p1)), ID="ps1")
ps2=Polygons(list(Polygon(p2)), ID="ps2")
ps3=Polygons(list(Polygon(p3)), ID="ps3")
ps4=Polygons(list(Polygon(p4)), ID="ps4")
ps5=Polygons(list(Polygon(p5)), ID="ps5")
ps6=Polygons(list(Polygon(p6)), ID="ps6")
sps = SpatialPolygons(list(ps1,ps2,ps3, ps4, ps5, ps6))
spdf=
SpatialPolygonsDataFrame(sps,data.frame(weight=c(0.1,0.1,0.3,0.4,0.45,0.6),row.names=c("ps1","ps2","ps3","ps4",
"ps5","ps6")))
sp.theme(set = TRUE, regions = list(col = brewer.pal(4,"RdYlGn")))
spplot(spdf, "weight", at=classIntervals(spdf$weight,4)$brks)

	[[alternative HTML version deleted]]

