Hi everybody

I have a town map with a polygon for every individual stand. I have
interview data in a SpatialPolygonsDataFrame (SPDF) for some of them. Now I
want to print a map in pdf (as large as A0 !)  that displays:

1. All stands in the town
2. The ones we have done interviews with in one of four colours depending in
the value of a categorical variable (factor) with four levels.
3. The stand number (which is also a variable in the data frame)

I have tried using plot() and spplot. With plot I can get 1 and 2 (very
nicely with thin lines for 1.) With spplot I can get 1. and 3. (labels
scaled correctly but lines very thick). I include a reproducible example of
how far I got.

x <- readShapePoly(system.file("shapes/sids.shp", package="maptools"))
x...@data$cat=sample(1:4,length(x...@data[,1]),replace=TRUE)
x...@data$select=sample(0:1,length(x...@data[,1]),replace=TRUE)
my.select=x[x$select==1,]plot(x,lwd=0.025,main="Whatever")
plot(my.select[which(my.select$cat==1),],lwd=0.05,col="green",add=TRUE)
plot(my.select[which(my.select$cat==2),],lwd=0.05,col="grey",add=TRUE)
plot(my.select[which(my.select$cat==3),],lwd=0.05,col="brown",add=TRUE)
plot(my.select[which(my.select$cat==4),],lwd=0.05,col="red",add=TRUE)
text(coordinates(x),x...@data$name,cex=0.025)

# Everything worked except the last line. Why?
# I have the colours but not the lables

# Now I try with spplot() ;
spplot(my.select,zcol="NAME",panel=function(...){
sp.polygons(my.select)
sp.text(coordinates(my.select),my.sel...@data$name,cex=0.5)
},colorkey=F)

# I don't have the colors yet but I have the label. How do I specify colour
for each category in my.sel...@data$col ?

Thanks in advance

best regards
Christiaan

        [[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

Reply via email to