[GRASS-user] merging small areas but keep raster categories

I'd like to merge small areas from a raster with their large neighbors.

I can do this with `r.clump` with the `minsize` argument.

But r.clump reclassifies everything, which is causing problems downstream with my workflow. I've tried working around this with `r.reclass.area ... mode=greater`, but that doesn't have the same functionality.

Can anyone suggest a workflow or tool that merges clumps but does not re-categorize them?

Thanks,

-k.

Hi Ken,

Did you try the rmarea method for r.reclass.area?

That converts to vector, runs v.clean with rmarea and then converts back to raster (if I understood correctly…

Cheers,

Stefan


From: grass-user grass-user-bounces@lists.osgeo.org on behalf of Ken Mankoff mankoff@gmail.com
Sent: Saturday, March 9, 2019 9:44:31 PM
To: grass-user
Subject: [GRASS-user] merging small areas but keep raster categories

I’d like to merge small areas from a raster with their large neighbors.

I can do this with r.clump with the minsize argument.

But r.clump reclassifies everything, which is causing problems downstream with my workflow. I’ve tried working around this with r.reclass.area ... mode=greater, but that doesn’t have the same functionality.

Can anyone suggest a workflow or tool that merges clumps but does not re-categorize them?

Thanks,

-k.


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Hi Stefan,

I just solved this with the following and was replying to my own message when yours came in.

r.clump -d input=basins output=basins_nosmall minsize=123
r.mode base=basins_nosmall cover=basins output=basins_merged

On 2019-03-10 at 12:06 +0100, Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote...

Did you try the rmarea method for r.reclass.area? That converts to
vector, runs v.clean with rmarea and then converts back to raster (if
I understood correctly...

The issue with rmarea is I don't want to remove small areas, I want to merge them with larger ones. If there is an island of only small ones, they are all dropped because there is nothing large to attach them to.

The r.clump code I use above correctly merges them into one, and then the r.mode line re-assigns the most common (largest area) original category value. The latter (keeping the main category value) was what I was having trouble with when I wrote my original message.

Thank you for thinking about the issue and replying,

  -k.