[R-sig-Geo] SGDF with NA values - SGDF2PCT()

Tim.Haering at lwf.bayern.de Tim.Haering at lwf.bayern.de
Mon Dec 13 10:49:45 CET 2010


Hello,

I want to convert my three-band SGDF into a single color vector using the SGDF2PCT() function in rgdal. Unfortunately my SGDF contains NA values. To plot it with image() this is no problem, because NAs were fully transparent, but if I want to convert my three bands with SGDF2PCT() I get an error message.
I guess there is an easy way to handle NA values in SpatialGridDataFrame. Can someone please help me?

Here an example:
> logo <- system.file("pictures/Rlogo.jpg", package="rgdal")[1]
> SGlogo <- readGDAL(logo)
> cols <- SGDF2PCT(SGlogo) ### works fine

### now introduce some NA values
> band3 <- SGlogo$band3
> band3[band3==0] <- NA
> SGlogo$band3 <- band3
> summary(SGlogo)
> cols <- SGDF2PCT(SGlogo)
Error in if (bmax == bmin) bmax <- bmin + ncolors : 
  missing value where TRUE/FALSE needed

Thank you.
TIM

----------------------------------------------------------------------------------- 
Tim Häring
Bavarian State Institute of Forest Research 
Department of Forest Ecology
Hans-Carl-von-Carlowitz-Platz 1
D-85354 Freising



More information about the R-sig-Geo mailing list