Hi Robert,

Many thanks for your answer, much appreciated!

Cheers, Lyndon


On Fri, Mar 30, 2012 at 3:02 PM, Robert J. Hijmans <r.hijmans@gmail.com>wrote:

> Lyndon,
>
> Here is a solution for your example:
>
> br2 <- reclass(br, cbind(NA, 255))
> plotRGB(br2, r = 1, g = 2, b = 3)
>
> But I have made a change in raster such that in future versions (> 1.9-77)
> you can set the background (NA) color like this:
>
> library(raster)
> b <- brick(system.file("external/rlogo.grd", package="raster"))
> plotRGB(b)
> b[40:70, 20:50] = NA
> plotRGB(b)
> plotRGB(b, bgcol='red')
>
>
> Best, Robert
>
>
>
>  On Fri, Mar 30, 2012 at 11:13 AM, Lyndon Estes <lyndon.estes@gmail.com>wrote:
>
>>  Dear List,
>>
>> I am trying to plot an RGB image using plotRGB, and I was wondering if
>> there is anyway to turn the NA regions of the image to a different color
>> (say white or grey)?
>>
>> For instance, in the following code, how to a turn the first and last 5
>> columns of the image something other than black?
>>
>> library(raster)
>> br <- brick(lapply(1:3, function(x) {
>>  r <- raster(nrow = 100, ncol = 100)
>>  r[] <- sample(0:255, ncell(r), replace = T)
>>  r[cellFromCol(r, colnr = c(1:5, 96:100))] <- NA
>>  return(r)
>> }))
>>
>> plotRGB(br, r = 1, g = 2, b = 3)
>>
>> Thanks in advance for your advice, and I will be happy to try alternate
>> RGB
>> plotting approaches as well.
>>
>> Cheers, Lyndon
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>

	[[alternative HTML version deleted]]

