[GRASS-user] Fwd: Re: remove small islands from vector areas

Ken Mankoff mankoff at gmail.com
Fri Jun 21 12:27:57 PDT 2019


On 2019-06-21 at 21:10 +02, Robert Nuske <rsn.mailinglists at gmail.com> wrote...
> If there is no way to only treat the islands/holes (which i don't know
> about), it will change the outer boundary as well. Fjord like
> structures will vanish. Neighboring areas might even merge if close
> enough. And since one can not control the buffer style of sharp edges
> (like in postgis, geos), everything will become "rounder".

Can you work in raster space or do you have to remain with resolution-agnostic vectors? I've solved this issue with maintaining coastlines in raster space by finding and saving the largest (or several largest) clumps (e.g. the ocean surrounding my domain), filling all holes which may involve filling the sea or growing the coastline, and then re-applying the saved clumps, thereby removing any artificially rounded coast.

r.clump input=raster output=clumps
clump_ID_largest=$(r.stats -c clumps sort=desc | head -n1 | cut -d" " -f1)
r.mapcalc "mask_ocean = if(clumps == ${clump_ID_largest}, null(), 1)"
r.mfilter -z input=raster output=raster_overfilled filter=filter.txt
r.mapcalc "raster_filled = raster_overfilled * mask_ocean" --o

  -k.


More information about the grass-user mailing list