Split polygon with linestring

280 views
Skip to first unread message

Paul Meems

unread,
Nov 12, 2014, 8:33:13 AM11/12/14
to nettopologysuite
Hi List,

I'm trying to split a polygon with a hole with a linestring.
I use this piece of code:
            var polygonizer = new Polygonizer();
            polygonizer.Add(field.Boundary.Union(splitline));
            var polygons = polygonizer.GetPolygons();
I get 3 polygons back. The top polygon is a simple one.
The bottom polygon has the hole.

I can't figure out which of the 3 polygons is the whole and how to add one of the polygons as a hole.

Doesn't NTS have a method that is already handling this for you?
It seems a rather trivial process.

Thanks,

Paul

Paul Meems 
Release manager, configuration manager
and forum moderator of MapWindow GIS.
www.mapwindow.org

Owner of MapWindow.nl - Support for
Dutch speaking users.
www.mapwindow.nl


The English presentations of the MapWindow GIS Conference 2014 are online.

FObermaier

unread,
Nov 12, 2014, 8:39:38 AM11/12/14
to nettopol...@googlegroups.com

reachg...@gmail.com

unread,
May 18, 2016, 11:35:48 PM5/18/16
to NetTopologySuite
Hi,

I ran the above example and didn't understand the output.

As in,

When "POLYGON((0 0, 0 100, 100 100, 100 0, 0 0), (10 10, 90 10, 90 90, 10 90, 10 10))" is split by "LINESTRING(50 -10, 50 110)", I would expect two polygons.
1. POLYGON ((0 0, 0 100, 50 100, 50 90, 10 90, 10 10, 50 10, 50 0, 0 0))
2. POLYGON((50 100, 100 100, 100 0, 50 0, 50 10, 90 10, 90 90, 50 90, 50 100))

but it seems to output only the first one.
What is wrong in my understanding?

Regards,
GreyMan
Reply all
Reply to author
Forward
0 new messages