[GRASS-user] making sense of r.reclass.area

Markus Metz markus.metz.giswork at gmail.com
Fri Nov 17 06:09:53 PST 2017


On Fri, Nov 17, 2017 at 1:40 PM, Ken Mankoff <mankoff at gmail.com> wrote:
>
> Hi Markus,
>
> Thanks for the reply. You're right that unclumped data was part of the
problem, but even with that realization and more testing things still don't
make sense. Specifically, the diagonal flag doesn't seem to work for rmarea
for me, or I'm not understanding how it should work.

OK, I understand now. With method=rmarea, r.reclass converts the raster
clumps to vector areas. That single cell in your example below, that either
belongs to the larger clump 1 (with -d) or forms a separate clump 2
(without -d) will always be a separate small vector area (topology or not
does not matter here) and thus will always be removed independent of the
2-cell clump. The vector approach is thus not working here as expected.

Incidentally I have added a minsize option to r.clump in GRASS 7.4 which
should work as expected. Try to use r.clump minsize=X (in number of cells)
instead of r.reclass.area method=rmarea mode=lesser.

Markus M

>
> I've now clumped my input (and also test this telling r.reclass.area to
clump the input by not using the "-c" flag). Text below appears OK in Gmail
for me but is best viewed in fixed-width font.
>
> # set up the environment
> grass72 -c EPSG:3413 ./Gclump
> g.region w=0 e=500 s=0 n=500 res=100 -p
> debug() { r.out.xyz -i input=$@  | cut -d"|" -f3 | xargs -n5; }
>
> r.mapcalc "foo = if(row() == 2 && ((col() > 1) && (col() < 4)) , 1,
null())" --o
> r.mapcalc "foo = if(row() == 3 && col() == 4, 1, foo)" --o
> r.mapcalc "foo = if(row() == 4 && col() == 2, 2, foo)" --o
>
> I think I've "clumped" the above, with diagonals, by assigning the 3
cells a value of 1 and the single cell a value of 2. Just to be sure, I'm
manually running r.clump 2x:
>
> r.clump input=foo output=foo_c      # no diagonals
> r.clump -d input=foo output=foo_cd  # diagonal
>
> debug foo
> debug foo_cd  # give the same result
> # * * * * *
> # * 1 1 * *
> # * * * 1 *
> # * 2 * * *
> # * * * * *
>
> And as expected,
>
> debug foo_c
> * * * * *
> * 1 1 * *
> * * * 2 *
> * 3 * * *
> * * * * *
>
> On 2017-11-17 at 08:45, Markus Metz <markus.metz.giswork at gmail.com> wrote:
> > On Mon, Nov 13, 2017 at 11:24 AM, Ken Mankoff <mankoff at gmail.com> wrote:
> >> Why does mode=rmarea appear to ignore the -d flag
> >
> > The -d flag only has an effect if clumps are created from the input.
> > If the -c flag is set, the input is already clumped and the -d flag
> > has no effect. This is (should be) independent of the mode.
>
> OK. So r.reclass.area with foo_cd (diagonal clumped) and the -c flag
should remove the small single cell, and retain the 3 cells with 1
diagonal, right?
>
> And this should be the same behavior as if if I pass in foo (unclumped),
no "-c" flag, and yes "-d" flag.
>
> r.reclass.area -c input=foo_cd output=o value=1 mode=lesser method=rmarea
--o --q && debug o
>
> Everything I run here produces the same result, regardless of which of
the three foo* rasters I pass in, or any of the three flag options (NONE,
-c, or -d).
>
> * * * * *
> * 1 1 * *
> * * * * *
> * * * * *
> * * * * *
>
>   -k.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20171117/eee4c93f/attachment-0001.html>


More information about the grass-user mailing list