forgot to copy the list

---------- Forwarded message ----------
From: steven mosher <moshersteven@gmail.com>
Date: Thu, Sep 23, 2010 at 1:14 PM
Subject: Re: [R-sig-Geo] using the 'mask' function to set NAs in 'raster'
To: Jason MacKenzie <jmackenzie@tnc.org>


To get an idea about how mask works, see the following. NA is the mask
value, Values in the input raster "pass through" the cells which are not
"NA"

 r <- raster(ncol=10, nrow=10)
 m <- raster(ncol=10, nrow=10)
 r[] <- runif(ncell(r)) * 10
 m[] <- runif(ncell(r))
 m[m <0.5] <- NA
mr <- mask(r, m)

  cellValues(r,cells=1:100)

 cellValues(m,cells=1:100)

  cellValues(mr,cells=1:100)

depending what you want the interaction to be you can change your mask, or
use the function 'cover'

On Thu, Sep 23, 2010 at 12:44 PM, Jason MacKenzie <jmackenzie@tnc.org>wrote:

> dear list members
>
> i want to create a new raster where all cells that are NA in my 'mask' are
> set to NA, but all other values stay the same as input rasters. instead of
> NAs, masked areas are getting returned as 0s (see counts below). am i
> missing a flag to set NAs?
>
> thanks in advance,
> j
>
>
>
> r    <- raster(raster.asc)
> m  <- raster(mask.asc)
> mr <- mask(r, m)
>
> > count (r, NA)
> [1] 20533362
> > count (m, NA)
> [1] 39269328
> > count (mr, NA)
> [1] 20533362
>
>
>
>
>
> --
>
> *Jason MacKenzie, PhD*
> *
> Climate Change Adaptation Fellow*
> The Nature Conservancy
> 201 Mission Street, 4th Floor
> San Francisco, CA 94105
> jmackenzie@tnc.org
>
> (415) 281 0472            [work]
> (415) 777 0244            [fax]
> (510) 717 1544            [cell]
> jasonbmackenzie        [skype]
>
>        [[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
>

	[[alternative HTML version deleted]]

