[GRASS-user] generalize polygons including holes

Hi GRASS-Users

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one class in
the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the "inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the right
http://i.imgur.com/hHKr15m.png

Suggestions are very welcome.

cheers
  robert

On 04/02/15 11:36, Robert Nuske wrote:

Hi GRASS-Users

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one class in
the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the "inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the original blue ones. Is that correct ? Are you sure that the original boundaries of the holes are identical to the new ones ? Could you display the result with polygon fill color set to transparent ?

Moritz

Hi Moritz & GRASS-List

> is there a way to generalize polygons including their holes?
> I am not too worried about topology, there are only polygons of one class
> in the dataset.
>
>
> I tried the following
> v.generalize in=m3 out=m5 type=area method=douglas threshold=5000
>
> which simplified the "outer boundaries" okay but did not touch the "inner
> boundaries"/ holes of the polygon.
>
>
> Outer boundaries are on the left side in the picture and holes on the
> right
> http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

This is GRASS 6.4.4 on ubuntu 14.04.

thanks for reading
  robert

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the "inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with GRASS 6.4.4, but it has been solved in GRASS 7. See the attached image where you have two holes: both have been generalized with method=douglas (black = original, red=lower threshold, blue=higher threshold). You can clearly see that generalization is also happening for the hole boundaries.

As GRASS 7 will come out really soon, and the current release candidates are quite stable, I recommend you switch to GRASS 7.

Moritz

(attachments)

test_v_generalise_holes.png

>>> is there a way to generalize polygons including their holes?
>>> I am not too worried about topology, there are only polygons of one
>>> class
>>> in the dataset.
>>>
>>>
>>> I tried the following
>>> v.generalize in=m3 out=m5 type=area method=douglas threshold=5000
>>>
>>> which simplified the "outer boundaries" okay but did not touch the
>>> "inner
>>> boundaries"/ holes of the polygon.
>>>
>>>
>>> Outer boundaries are on the left side in the picture and holes on the
>>> right
>>> http://i.imgur.com/hHKr15m.png
>>
>> It looks like the red boundaries are the generalized version of the
>> original blue ones. Is that correct ? Are you sure that the original
>> boundaries of the holes are identical to the new ones ? Could you
>> display the result with polygon fill color set to transparent ?
>
> That's right.
> Original vector map is blue and simplified vector is red.
> Both layers are 50% opaque in the following image
> http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with
GRASS 6.4.4, but it has been solved in GRASS 7. See the attached image
where you have two holes: both have been generalized with method=douglas
(black = original, red=lower threshold, blue=higher threshold). You can
clearly see that generalization is also happening for the hole boundaries.

As GRASS 7 will come out really soon, and the current release candidates
are quite stable, I recommend you switch to GRASS 7.

Thanks a lot for testing on current and future GRASS Versions.
Will use this as reason to finally try GRASS 7 :wink:

I actually couldn't believe that it is not a user error. Seemed a very common
requirement to treat outer and inner boundaries alike while simplifying.

cheers
  robert

On Thu, Feb 5, 2015 at 9:36 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one
class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the
"inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with GRASS
6.4.4, but it has been solved in GRASS 7. See the attached image where you
have two holes: both have been generalized with method=douglas (black =
original, red=lower threshold, blue=higher threshold). You can clearly see
that generalization is also happening for the hole boundaries.

The right hole has not been generalized properly, the resultant
boundary intersects with itself. This has been fixed in GRASS 7
recently. Do you get the same result with recent GRASS 7.1?

v.generalize does not distinguish between outer and inner rings, it
simply goes through all boundaries and generalizes each one.

Markus M

As GRASS 7 will come out really soon, and the current release candidates are
quite stable, I recommend you switch to GRASS 7.

Moritz

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

On 05/02/15 10:06, Markus Metz wrote:

On Thu, Feb 5, 2015 at 9:36 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one
class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the
"inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with GRASS
6.4.4, but it has been solved in GRASS 7. See the attached image where you
have two holes: both have been generalized with method=douglas (black =
original, red=lower threshold, blue=higher threshold). You can clearly see
that generalization is also happening for the hole boundaries.

The right hole has not been generalized properly, the resultant
boundary intersects with itself. This has been fixed in GRASS 7
recently. Do you get the same result with recent GRASS 7.1?

No. The example was with GRASS 7.0 from a week or two ago. In GRASS 7.1 no more intersection, but actually for that hole the generalization is less with a higher threshold (see attached image). I've attached the vector file I used as a GRASS 7 vector pack for the NC location.

The settings I used were:

v.generalize test method=douglas thresh=100 out=test_gen_100
v.generalize test method=douglas thresh=500 out=test_gen_500

v.generalize does not distinguish between outer and inner rings, it
simply goes through all boundaries and generalizes each one.

And this has always been the case or this is specific to GRASS7 ?

Moritz

(attachments)

test_generalize_holes.png
test.pack (3.23 KB)

On Thu, Feb 5, 2015 at 11:50 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

On 05/02/15 10:06, Markus Metz wrote:

On Thu, Feb 5, 2015 at 9:36 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one
class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the
"inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with
GRASS
6.4.4, but it has been solved in GRASS 7. See the attached image where
you
have two holes: both have been generalized with method=douglas (black =
original, red=lower threshold, blue=higher threshold). You can clearly
see
that generalization is also happening for the hole boundaries.

The right hole has not been generalized properly, the resultant
boundary intersects with itself. This has been fixed in GRASS 7
recently. Do you get the same result with recent GRASS 7.1?

No. The example was with GRASS 7.0 from a week or two ago.

OK, the test was missing in 7.0, I have now backported it to 7.0 in r64471

In GRASS 7.1 no
more intersection, but actually for that hole the generalization is less
with a higher threshold (see attached image).

That hole is actually not generalized at all with thresh=500 because
it would damage topology.

I've attached the vector file
I used as a GRASS 7 vector pack for the NC location.

The settings I used were:

v.generalize test method=douglas thresh=100 out=test_gen_100
v.generalize test method=douglas thresh=500 out=test_gen_500

v.generalize does not distinguish between outer and inner rings, it
simply goes through all boundaries and generalizes each one.

And this has always been the case or this is specific to GRASS7 ?

This has always been the case.

Markus M

On 05/02/15 14:49, Markus Metz wrote:

On Thu, Feb 5, 2015 at 11:50 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

On 05/02/15 10:06, Markus Metz wrote:

On Thu, Feb 5, 2015 at 9:36 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one
class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the
"inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with
GRASS
6.4.4, but it has been solved in GRASS 7. See the attached image where
you
have two holes: both have been generalized with method=douglas (black =
original, red=lower threshold, blue=higher threshold). You can clearly
see
that generalization is also happening for the hole boundaries.

The right hole has not been generalized properly, the resultant
boundary intersects with itself. This has been fixed in GRASS 7
recently. Do you get the same result with recent GRASS 7.1?

No. The example was with GRASS 7.0 from a week or two ago.

OK, the test was missing in 7.0, I have now backported it to 7.0 in r64471

In GRASS 7.1 no
more intersection, but actually for that hole the generalization is less
with a higher threshold (see attached image).

That hole is actually not generalized at all with thresh=500 because
it would damage topology.

Maybe a little message would be helpful here to inform the user about this ?

I've attached the vector file
I used as a GRASS 7 vector pack for the NC location.

The settings I used were:

v.generalize test method=douglas thresh=100 out=test_gen_100
v.generalize test method=douglas thresh=500 out=test_gen_500

v.generalize does not distinguish between outer and inner rings, it
simply goes through all boundaries and generalizes each one.

And this has always been the case or this is specific to GRASS7 ?

This has always been the case.

Then why doesn't there seem to be any generalization happening for the hole boundaries of the test dataset with grass64release ?

Moritz

On Thu, Feb 5, 2015 at 4:56 PM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

On 05/02/15 14:49, Markus Metz wrote:

On Thu, Feb 5, 2015 at 11:50 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

On 05/02/15 10:06, Markus Metz wrote:

On Thu, Feb 5, 2015 at 9:36 AM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

[Please keep conversations on the list]

On 04/02/15 16:12, Robert Nuske wrote:

Hi Moritz

is there a way to generalize polygons including their holes?
I am not too worried about topology, there are only polygons of one
class
in the dataset.

I tried the following
v.generalize in=m3 out=m5 type=area method=douglas threshold=5000

which simplified the "outer boundaries" okay but did not touch the
"inner
boundaries"/ holes of the polygon.

Outer boundaries are on the left side in the picture and holes on
the
right
http://i.imgur.com/hHKr15m.png

It looks like the red boundaries are the generalized version of the
original blue ones. Is that correct ? Are you sure that the original
boundaries of the holes are identical to the new ones ? Could you
display the result with polygon fill color set to transparent ?

That's right.
Original vector map is blue and simplified vector is red.
Both layers are 50% opaque in the following image
http://i.imgur.com/Rsx7Kh1.png

I imagine you are using GRASS 6 ? I can confirm the issue there with
GRASS
6.4.4, but it has been solved in GRASS 7. See the attached image where
you
have two holes: both have been generalized with method=douglas (black =
original, red=lower threshold, blue=higher threshold). You can clearly
see
that generalization is also happening for the hole boundaries.

The right hole has not been generalized properly, the resultant
boundary intersects with itself. This has been fixed in GRASS 7
recently. Do you get the same result with recent GRASS 7.1?

No. The example was with GRASS 7.0 from a week or two ago.

OK, the test was missing in 7.0, I have now backported it to 7.0 in r64471

In GRASS 7.1 no
more intersection, but actually for that hole the generalization is less
with a higher threshold (see attached image).

That hole is actually not generalized at all with thresh=500 because
it would damage topology.

Maybe a little message would be helpful here to inform the user about this ?

This message exists already:

v.generalize test method=douglas thresh=500 out=test_gen_500
...
Generalization (douglas)...
100%
WARNING: 1 boundaries were not modified because modification would damage
         topology
...

I've attached the vector file
I used as a GRASS 7 vector pack for the NC location.

The settings I used were:

v.generalize test method=douglas thresh=100 out=test_gen_100
v.generalize test method=douglas thresh=500 out=test_gen_500

v.generalize does not distinguish between outer and inner rings, it
simply goes through all boundaries and generalizes each one.

And this has always been the case or this is specific to GRASS7 ?

This has always been the case.

Then why doesn't there seem to be any generalization happening for the hole
boundaries of the test dataset with grass64release ?

With the test dataset you provided, GRASS 6.4 does generalize the hole
boundaries. I do not have the problem vector of Robert, so I can not
say if the hole boundaries in that vector are generalized or not.

Markus M

Hi Markus

>>>> v.generalize does not distinguish between outer and inner rings, it
>>>> simply goes through all boundaries and generalizes each one.
>>>
>>> And this has always been the case or this is specific to GRASS7 ?
>>
>> This has always been the case.
>
> Then why doesn't there seem to be any generalization happening for the
> hole
> boundaries of the test dataset with grass64release ?

With the test dataset you provided, GRASS 6.4 does generalize the hole
boundaries. I do not have the problem vector of Robert, so I can not
say if the hole boundaries in that vector are generalized or not.

Please find attached a location with a test dataset (snipped of larger vector
map) and two images from generalizations carried out in GRASS 6.4.4
(6.4.4-1~trusty5 from ppa:ubuntugis-unstable) and GRASS 7.0
(7.0.0+1svn64474~ubuntu14.04.1 from ppa:grass-devel).
Blue layer is generalized and red one is the original both at 50%
transparency.

For me, the results from GRASS 7.0 look as expected (inner rings generalized)
but v.generalize in GRASS 6.4 seems not to treat inner rings.

GRASS 6.4.4
-----------------------------------------------------------
v.generalize in=test_data out=test_gen method=douglas thresh=5000

Number of vertices for selected lines reduced from 907 to 82 (9%).
v.generalize complete.

GRASS 7.0
-----------------------------------------------------------
v.build map=test_data
v.generalize in=test_data out=test_gen method=douglas thresh=5000

v.generalize complete. Number of vertices for selected features reduced
from 4605 to 451 (9%).

cheers,
  robert

(attachments)

test_location.gz (54.2 KB)
generalize_70.png
generalize_644.png

On Fri, Feb 6, 2015 at 11:08 AM, Robert Nuske <rnuske@gwdg.de> wrote:

Hi Markus

>>>> v.generalize does not distinguish between outer and inner rings, it
>>>> simply goes through all boundaries and generalizes each one.
>>>
>>> And this has always been the case or this is specific to GRASS7 ?
>>
>> This has always been the case.
>
> Then why doesn't there seem to be any generalization happening for the
> hole
> boundaries of the test dataset with grass64release ?

With the test dataset you provided, GRASS 6.4 does generalize the hole
boundaries. I do not have the problem vector of Robert, so I can not
say if the hole boundaries in that vector are generalized or not.

Please find attached a location with a test dataset (snipped of larger vector
map) and two images from generalizations carried out in GRASS 6.4.4
(6.4.4-1~trusty5 from ppa:ubuntugis-unstable) and GRASS 7.0
(7.0.0+1svn64474~ubuntu14.04.1 from ppa:grass-devel).
Blue layer is generalized and red one is the original both at 50%
transparency.

For me, the results from GRASS 7.0 look as expected (inner rings generalized)
but v.generalize in GRASS 6.4 seems not to treat inner rings.

Thanks for the test location, I could reproduce it, fixed in relbr64 r64478.

Markus M

GRASS 6.4.4
-----------------------------------------------------------
v.generalize in=test_data out=test_gen method=douglas thresh=5000

Number of vertices for selected lines reduced from 907 to 82 (9%).
v.generalize complete.

GRASS 7.0
-----------------------------------------------------------
v.build map=test_data
v.generalize in=test_data out=test_gen method=douglas thresh=5000

v.generalize complete. Number of vertices for selected features reduced
from 4605 to 451 (9%).

cheers,
  robert

Hi Markus,

>> >>>> v.generalize does not distinguish between outer and inner rings, it
>> >>>> simply goes through all boundaries and generalizes each one.
>> >>>
>> >>> And this has always been the case or this is specific to GRASS7 ?
>> >>
>> >> This has always been the case.
>> >
>> > Then why doesn't there seem to be any generalization happening for the
>> > hole
>> > boundaries of the test dataset with grass64release ?
>>
>> With the test dataset you provided, GRASS 6.4 does generalize the hole
>> boundaries. I do not have the problem vector of Robert, so I can not
>> say if the hole boundaries in that vector are generalized or not.
>
> Please find attached a location with a test dataset (snipped of larger
> vector map) and two images from generalizations carried out in GRASS
> 6.4.4 (6.4.4-1~trusty5 from ppa:ubuntugis-unstable) and GRASS 7.0
> (7.0.0+1svn64474~ubuntu14.04.1 from ppa:grass-devel).
> Blue layer is generalized and red one is the original both at 50%
> transparency.
>
>
> For me, the results from GRASS 7.0 look as expected (inner rings
> generalized) but v.generalize in GRASS 6.4 seems not to treat inner
> rings.

Thanks for the test location, I could reproduce it, fixed in relbr64 r64478.

Thanks for fixing it!

cheers,
  robert