[GRASS-user] calculate mode value on moving window (with mapalgebra) with null value cells

Moritz Lennert mlennert at club.worldonline.be
Tue Jun 19 04:33:42 PDT 2012


On 19/06/12 10:15, G. Allegri wrote:
> I need to assign values to a the cells on the "border" of a raster. The
> inside and the outside are distinguished by having or not having null
> values assigned.
> I also need to keep the other cell values (internals) untouched.
> I thought to use a mapcalc expression like the following (knowing the
> the external cells have value 9999)
>
> if(A==9999,max(A[1,1],A[1,0],A[1,-1],A[0,-1],A[-1,-1],A[-1,0],A[-1,1],A[0,1]),A)

How about using an isnull() function on each cell, i.e.:

if(A==9999,max(if(isnull(A[1,1]),0,A[1,1]),if(isnull(A[1,0]),0,A[1,0]), 
etc, ),A)

?

Moritz


More information about the grass-user mailing list