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

G. Allegri giohappy at gmail.com
Tue Jun 19 09:36:37 PDT 2012


Yes, with r.neighbors I woul chenge the values to NULL, but I don't know
how to solve the problem of applying the filter only to the cells with a
specific value (involving only the values of their neighbors).
My border cells have assigned a 10000 value. I'm working on a DEM., so this
fictious value is a way to code my borders. I want to apply the filter only
on these cells, while leaving the others (not on the border) unaltered.
With r.mapcalc I use an if() statement, but with r.neighbors I would need a
MASK.

giovanni

2012/6/19 Markus Metz <markus.metz.giswork at googlemail.com>

> On Tue, Jun 19, 2012 at 6:15 PM, G. Allegri <giohappy at gmail.com> wrote:
> >> AFAICT, r.neighbors ignores NULL values and assigns the new value from
> >> the surrounding non-NULL values. You could then patch your original
> >> map with the output of r.neighbors.
> >
> >
> > I have considered r.neighbors but I need to apply the filter only to some
> > specific categories (border cells in my case). A MASK wouldn't solve my
> > problem, because it would mask the neighbors...
>
> You could replace 9999 (according to your first post the category of
> border cells) with NULL, then run r.neighbors, without a MASK?
>
> Markus M
>
> >
> > giovanni
> >
> >
> >>
> >>
> >> HTH,
> >>
> >> Markus M
> >>
> >> >
> >> > giovanni
> >> >
> >> >
> >> > 2012/6/19 Marcello Gorini <gorini at gmail.com>
> >> >>
> >> >>
> >> >>
> >> >> 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.
> >> >>>
> >> >>
> >> >>  Hey,
> >> >>
> >> >> Check out r.grow. I am pretty sure you can modify the example given
> in
> >> >> the
> >> >> manual to find the borders of your raster. Something like:
> >> >>
> >> >> # creates an inverted raster from your raster
> >> >> > r.mapcalc "raster_inverted=if(isnull(raster,1,null())"
> >> >> # grow this inverted raster by one cell
> >> >> > r.grow in=raster_inverted out=raster_inverted_grown
> >> >> # now both rasters overlap at the border, so you can do whatever you
> >> >> want
> >> >> with it, for instance, extract it
> >> >> > r.mapcalc "border=if(raster_inverted_grown==1 &&
> >> >> > isnull(raster)==0,raster,null())"
> >> >>
> >> >> Hope it helps.
> >> >>
> >> >> Cheers,
> >> >> Marcello.
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > grass-user mailing list
> >> > grass-user at lists.osgeo.org
> >> > http://lists.osgeo.org/mailman/listinfo/grass-user
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20120619/51719c4c/attachment-0001.html>


More information about the grass-user mailing list