[R-sig-Geo] summing rasters with a condition given by other rasters

Éder Comunello comunello.eder at gmail.com
Mon May 18 17:22:54 CEST 2015


Hello, Martin!

Did you try use mean() function with "na.rm=T" argument?

Éder Comunello <c <comunello.eder at gmail.com>omunello.eder at gmail.com>
Dourados, MS - [22 16.5'S, 54 49'W]

2015-05-17 7:10 GMT-04:00 Martin Brandt <martin.brandt at mailbox.org>:

> There's another issue:
>
> using Ben's great function:
>
> sum_segment <- function(x, ...) {
> sum(x[(x[1]+2):(x[2] + 2)],...)
> }
>
> what to do if the rasters in the brick contain NA values?
>
> I thought about replacing them with 0:
>
> b <- reclassify(b, cbind(NA, 0))
>
> however, if I want means instead of sums
>
> sum_segment <- function(x, ...) {
> mean(x[(x[1]+2):(x[2] + 2)],...)
> }
>
> this influences the result.....is there a solution to simply omit pixels
> with NAs when the mean or sum in the function are calculated?
>
>
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/summing-rasters-with-a-condition-given-by-other-rasters-tp7588222p7588263.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list