Dear list members,

I'm having trouble creating a rgb color composite based one a multiple grid object. Both the SGDF2PCT function from rgdal package and the  plotRGB function from raster package can not handle NA's. For my  work it is necessary to include No Data values for masking the study area.


Is there any way to combine rgdal or raster objects in a rgb color mixture  with No Data values??? My two approaches are given below.

Very Great Thanks for any help!!!

Carsten

1. Approach

library(rgdal)

vismaps = readGDAL("Hasenheide")
vismaps$red = vismaps$band14
vismaps$green = vismaps$band7
vismaps$blue = vismaps$band1

###Display as a RGB image###
RGBimg = SGDF2PCT(vismaps[c("red", "green", "blue")], ncolors=256,
adjust.bands=TRUE)

##########Error in if (bmax == bmin) bmax <- bmin + ncolors : 
  missing value where TRUE/FALSE needed################

col<-rgb(d1@data[[4]],d1@data[[7]],d1@data[[1]])

vismaps$idx <- RGBimg$idx
image(vismaps, "idx", col=RGBimg$ct) 

 

 
2. Approach

library(raster)

d1<-readGDAL('Hasenheide')
fn<-stack(raster(d1,14),raster(d1,7),raster(d1,1))

###Display as a RGB image###
plotRGB(fn,scale=1,1,2,3)

################Error in rgb(getValues(r), getValues(g), getValues(b), max = scale) : 
  color intensity nan, not in [0,1]#############################################


 

	[[alternative HTML version deleted]]

