I'm plotting a series ( a few hundred )  of  rasters that are filled with
landcover data,   integers

Normally, these are  integers such as  c(11,12,21,22,23,31,32,41,42,43,51,
 etc etc)
where each value corresponds to a landcover type.

I want all of these plots to have consistent colors and legends. However,
not every plot has
a complete set of land cover types.   What I tried was the following.

I took all the landcover values in the raster and reclassified them so that
I got a  seq from
1..n.   and then I made a vector of colors the same length

However, when a land type if missing I still get   errors.  I tried using
 breaks() and that
helped a little but I would still get  errors

Here is a toy example

r <- raster(nrow=10,ncol=10)
#  slot in some values
r[1:12]<-0
r[13:34]<-1
r[35:76]<-2
r[77:95]<-3
r[96:100]<-4

#  define colors
myColors <- c("black","green","orange","pink","blue")

plot(r,col=myColors)

#  swicth the 4 to 0
r <- subs(r,data.frame(Id= c(0,1,2,3,4), v=c(0,1,2,3,0)))

plot(r,col=myColors)

Another way to ask this is how do I get the function to recognize that I
watch categorical colors instead of
continuous ones. or should I change the colors dynamically according to the
actual values found in that
particular map.

I tried  breaks() no joy


Steve

	[[alternative HTML version deleted]]

