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

-------- Weitergeleitete Nachricht --------
Betreff: Re: [GRASS-user] remove small islands from vector areas
Datum: Fri, 21 Jun 2019 13:47:52 +0200
Von: Robert Nuske <rsn.mailinglists@gmail.com>
An: Stefan Blumentrath <Stefan.Blumentrath@nina.no>

Hi Stefan,

as far as I understood does rmarea that remove small areas but not islands (holes) within areas. At least i didn't find a way to remove islands with v.clean.

thanks
   robert

Am 21.06.19 um 13:06 schrieb Stefan Blumentrath:

Hi Robert,

Did you have a look at v.clean:
https://grass.osgeo.org/grass77/manuals/v.clean.html
with
tool=rmarea >

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Robert Nuske
Sent: fredag 21. juni 2019 12:33
To: grass-user <grass-user@lists.osgeo.org>
Subject: [GRASS-user] remove small islands from vector areas

Dear Listers,

sorry, it's me again.

I want to remove islands smaller than a certain threshold from my vector map or if that is not possible all islands.

I found some trick on an old manual page of v.extract. But this does not work anymore. Is there a new trick?

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

Ah, OK. Got that wrong, sorry.

I don`t think holes have an area (but I may be wrong)....
So you might have to add a centroid first?
https://grass.osgeo.org/grass76/manuals/v.centroids.html

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Robert Nuske
Sent: fredag 21. juni 2019 13:49
To: grass-user <grass-user@lists.osgeo.org>
Subject: [GRASS-user] Fwd: Re: remove small islands from vector areas

-------- Weitergeleitete Nachricht --------
Betreff: Re: [GRASS-user] remove small islands from vector areas
Datum: Fri, 21 Jun 2019 13:47:52 +0200
Von: Robert Nuske <rsn.mailinglists@gmail.com>
An: Stefan Blumentrath <Stefan.Blumentrath@nina.no>

Hi Stefan,

as far as I understood does rmarea that remove small areas but not islands (holes) within areas. At least i didn't find a way to remove islands with v.clean.

thanks
   robert

Am 21.06.19 um 13:06 schrieb Stefan Blumentrath:

Hi Robert,

Did you have a look at v.clean:
https://grass.osgeo.org/grass77/manuals/v.clean.html
with
tool=rmarea >

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of
Robert Nuske
Sent: fredag 21. juni 2019 12:33
To: grass-user <grass-user@lists.osgeo.org>
Subject: [GRASS-user] remove small islands from vector areas

Dear Listers,

sorry, it's me again.

I want to remove islands smaller than a certain threshold from my vector map or if that is not possible all islands.

I found some trick on an old manual page of v.extract. But this does not work anymore. Is there a new trick?

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

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

···

On 21/06/2019 15:18, Stefan Blumentrath wrote:

Ah, OK. Got that wrong, sorry.

I don`t think holes have an area (but I may be wrong)....
So you might have to add a centroid first?
[https://grass.osgeo.org/grass76/manuals/v.centroids.html](https://grass.osgeo.org/grass76/manuals/v.centroids.html)

Cheers
Stefan

-----Original Message-----
From: grass-user [<grass-user-bounces@lists.osgeo.org>](mailto:grass-user-bounces@lists.osgeo.org) On Behalf Of Robert Nuske
Sent: fredag 21. juni 2019 13:49
To: grass-user [<grass-user@lists.osgeo.org>](mailto:grass-user@lists.osgeo.org)
Subject: [GRASS-user] Fwd: Re: remove small islands from vector areas

-------- Weitergeleitete Nachricht --------
Betreff: Re: [GRASS-user] remove small islands from vector areas
Datum: Fri, 21 Jun 2019 13:47:52 +0200
Von: Robert Nuske [<rsn.mailinglists@gmail.com>](mailto:rsn.mailinglists@gmail.com)
An: Stefan Blumentrath [<Stefan.Blumentrath@nina.no>](mailto:Stefan.Blumentrath@nina.no)

Hi Stefan,

as far as I understood does rmarea that remove small areas but not islands (holes) within areas. At least i didn't find a way to remove islands with v.clean.

When you say “remove islands” do you mean to “fill” small holes, and make them part of the surrounding polygon? If so, then this the procedure works:

First buffer the original polygon by some distance “dist” that is big enough to cover what you consider “small”.

Then buffer again by “-dist”.

The small holes get filled on the first buffer, and the original polygons are restored without those holes with the negative distance by the second buffer.

thanks
   robert

Am 21.06.19 um 13:06 schrieb Stefan Blumentrath:

Hi Robert,

Did you have a look at v.clean:
[https://grass.osgeo.org/grass77/manuals/v.clean.html](https://grass.osgeo.org/grass77/manuals/v.clean.html)
with
tool=rmarea >

Cheers
Stefan

-----Original Message-----
From: grass-user [<grass-user-bounces@lists.osgeo.org>](mailto:grass-user-bounces@lists.osgeo.org) On Behalf Of 
Robert Nuske
Sent: fredag 21. juni 2019 12:33
To: grass-user [<grass-user@lists.osgeo.org>](mailto:grass-user@lists.osgeo.org)
Subject: [GRASS-user] remove small islands from vector areas

Dear Listers,

sorry, it's me again.

I want to remove islands smaller than a certain threshold from my vector map or if that is not possible all islands.

I found some trick on an old manual page of v.extract. But this does not work anymore. Is there a new trick?

thnaks
   robert
_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)

_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)
_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)
-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

>>>>> I want to remove islands smaller than a certain threshold from my
>>>>> vector map or if that is not possible all islands.
>>>>>
>>>>> I found some trick on an old manual page of v.extract. But this
>>>>> does not work anymore. Is there a new trick?

>>>> Did you have a look at v.clean:
>>>> https://grass.osgeo.org/grass77/manuals/v.clean.html
>>>> with tool=rmarea

>>> as far as I understood, rmarea does remove small areas but not
>>> islands (holes) within areas. At least i didn't find a way to remove
>>> islands with v.clean.

>> Ah, OK. Got that wrong, sorry.
>>
>> I don`t think holes have an area (but I may be wrong)....
>> So you might have to add a centroid first?
>> https://grass.osgeo.org/grass76/manuals/v.centroids.html

When you say "remove islands" do you mean to "fill" small holes, and make them part of the surrounding polygon? If so, then this the procedure works:

First buffer the original polygon by some distance "dist" that is big enough to cover what you consider "small".

Then buffer again by "-dist".

The small holes get filled on the first buffer, and the original polygons are restored without those holes with the negative distance by the second buffer.

I guess you hint towards mathematical morphology (dilation+erosion) in the vector world.

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".

thanks
   robert

On Fri, Jun 21, 2019 at 2:19 PM Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

Ah, OK. Got that wrong, sorry.

I don`t think holes have an area (but I may be wrong)…
So you might have to add a centroid first?
https://grass.osgeo.org/grass76/manuals/v.centroids.html

No, v.clean tool=rmarea also removes holes inside areas, at least it should. It would be a bug if holes smaller than threshold are not removed.

Markus M

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Robert Nuske
Sent: fredag 21. juni 2019 13:49
To: grass-user <grass-user@lists.osgeo.org>
Subject: [GRASS-user] Fwd: Re: remove small islands from vector areas

-------- Weitergeleitete Nachricht --------
Betreff: Re: [GRASS-user] remove small islands from vector areas
Datum: Fri, 21 Jun 2019 13:47:52 +0200
Von: Robert Nuske <rsn.mailinglists@gmail.com>
An: Stefan Blumentrath <Stefan.Blumentrath@nina.no>

Hi Stefan,

as far as I understood does rmarea that remove small areas but not islands (holes) within areas. At least i didn’t find a way to remove islands with v.clean.

thanks
robert

Am 21.06.19 um 13:06 schrieb Stefan Blumentrath:

Hi Robert,

Did you have a look at v.clean:
https://grass.osgeo.org/grass77/manuals/v.clean.html
with
tool=rmarea >

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of
Robert Nuske
Sent: fredag 21. juni 2019 12:33
To: grass-user <grass-user@lists.osgeo.org>
Subject: [GRASS-user] remove small islands from vector areas

Dear Listers,

sorry, it’s me again.

I want to remove islands smaller than a certain threshold from my vector map or if that is not possible all islands.

I found some trick on an old manual page of v.extract. But this does not work anymore. Is there a new trick?

thnaks
robert


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


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


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

On 2019-06-21 at 21:10 +02, Robert Nuske <rsn.mailinglists@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.

Am 21.06.19 um 21:27 schrieb Ken Mankoff:

On 2019-06-21 at 21:10 +02, Robert Nuske <rsn.mailinglists@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.

Interesting idea. Using the ocean like a stencil. Will think about it. Could work similarly in vector world.

Will have to test first if Markus Metz is right and v.clean rmarea does what I want. Maybe i haven't studied carefully enough my tests.

Thanks Ken

regards
robert