[GRASS-user] filtering raster outliers

Hi GRASS list,

I'm trying to filter out some outliers on a raster map, and wondering which approach is considered better. I'm also having trouble figuring out the exact syntax for the r.mapcalc approach.

I can remove the top and bottom 1% of outliers with this:

r.out.xyz input=map_in | r.in.xyz input=- output=map_out trim=1

An other option would be (something like) the following:

p=`r.univar map=RUh percentile=99 -e | grep "99th percentile:" | cut -d: -f2`
r.mapcalc "map_out = if(map_in * (map_in > ${p}), map_in, 0, 0)"

The xyz approach also filters the bottom and top 1%, while the mapcalc only filters the top 1%.

Other than that difference, are there other differences I'm not aware of? Which is a more "grassy" approach?

Thanks,

  -k.
  

On 2016-02-16 at 10:50, Ken Mankoff <mankoff@gmail.com> wrote:

I'm also having trouble figuring out the exact syntax for the
r.mapcalc approach.

r.mapcalc "map_out = if(map_in * (map_in > ${p}), map_in, 0, 0)"

I figured out my mapcalc issue. Should be "map_in < ${p}".

It also seems that mapcalc is several times faster than the export/import method. I assume that means it is the correct approach for filtering like this.

  -k.