[Boost-users] Boost.Geometry: Correct use of multi-part polygons

593 views
Skip to first unread message

John Lilley

unread,
Feb 20, 2013, 10:29:53 AM2/20/13
to Boost...@lists.boost.org

Greetings, I am looking for some guidance around the correct creation and use of multi-part polygons.  I am a bit confused about when to use each of the following:

·         Polygon with multiple rings

·         Vector of polygons

·         Polygon set

·         Set/vector of polygons, each potentially containing multiple rings

 

I gather from this example picture:

http://geometrylibrary.geodan.nl/03__polygon__example_8cpp-example.html

 

That if one wants holes to be opened as a result of intersection, they need to be rings as opposed to polygon sets or vectors of polygons?

 

An example would be polygon(s) representing an island chain.  Some of the islands are atolls and as such have a hole in the middle.  What would a representation of this set of islands look like?

 

And, what If I don't know if I have "real" rings (interior) vs just a collection of polygons (like I got this from an external source that doesn’t have the same model).  If I just throw a pile of points at a polygon and call clean(), will that magic everything up for me?

 

john

 

 

Barend Gehrels

unread,
Feb 20, 2013, 3:36:59 PM2/20/13
to boost...@lists.boost.org
Hi John,


On 20-2-2013 16:29, John Lilley wrote:

Greetings, I am looking for some guidance around the correct creation and use of multi-part polygons.  I am a bit confused about when to use each of the following:

·         Polygon with multiple rings

·         Vector of polygons

·         Polygon set

·         Set/vector of polygons, each potentially containing multiple rings

 

I gather from this example picture:

http://geometrylibrary.geodan.nl/03__polygon__example_8cpp-example.html


Note that this documentation is VERY old. The correct docs are here:
http://www.boost.org/doc/libs/1_53_0/libs/geometry/doc/html/index.html

Examples like above are not included in the doc's, but they still exist in the SVN tree.



 

That if one wants holes to be opened as a result of intersection, they need to be rings as opposed to polygon sets or vectors of polygons?



Hmm, no... If two polygons, or multipolygons, do have the normal winding order, any holes are generated automatically. With normal I mean, w.r.t. to the specified clockwise order. If you use boost::geometry polygons, they are by default ordered clockwise.

In "normal" (multi)polygons, exterior rings are ordered clockwise, interior rings are ordered counter clockwise. This is an often-used convention.

If your polygons are not like that, just use boost::geometry::correct


 

An example would be polygon(s) representing an island chain.  Some of the islands are atolls and as such have a hole in the middle.  What would a representation of this set of islands look like?


This is a multi polygon.

 

And, what If I don't know if I have "real" rings (interior) vs just a collection of polygons (like I got this from an external source that doesn’t have the same model).  If I just throw a pile of points at a polygon and call clean(), will that magic everything up for me?


Not clean().  Where did you get that from?

Currently there is not a function like that, but dissolve in the extensions would target this functionality. Correct works only for the direction of rings, not to remove interior overlaps.


Regards, Barend

Barend Gehrels

unread,
Feb 20, 2013, 4:04:38 PM2/20/13
to boost...@lists.boost.org
Hi John,

I realized I did not answer the first part explicitly:


On 20-2-2013 16:29, John Lilley wrote:

Greetings, I am looking for some guidance around the correct creation and use of multi-part polygons.  I am a bit confused about when to use each of the following:

·         Polygon with multiple rings

·         Vector of polygons

·         Polygon set

·         Set/vector of polygons, each potentially containing multiple rings

 


A polygon (in Boost.Geometry) can have one exterior ring, and zero or mor interior rings. So multiple in the sense that there can be any number of holes, but not more than one exterior ring. The exterior ring should not be self intersecting.

There are multi_polygons. This is a collection (vector, set, deque, whatever you call it) of polygons. They should not be mutually intersecting though.


These are common used definitions, defined by OGC. Just found nice descriptions by OpenStreetMap: http://wiki.openstreetmap.org/wiki/Multipolygon

or see this page: http://www.tankonyvtar.hu/hu/tartalom/tamop425/0027_SDO4/ch01s02.html

they explain it in more detail.


Regards, Barend

John Lilley

unread,
Feb 20, 2013, 4:30:38 PM2/20/13
to Barend Gehrels, boost...@lists.boost.org
Thanks, let me see if I understand.  It sounds like if I want a set of islands, some with lakes, that I should make each island a separate polygon, and each lake an inner ring within the polygon.  The overall set of islands would be a multipolygon, right?

Is multipolygon different than a vector of polygons like that returned by intersect()?

So if I just get a set of undifferentiated rings, it sounds like I need to determine which are contained by others and and combine them as inner/outer rings.

Once that is done can I intersect polygon against multipolygon or multipolygon against multipolygon easily?

--John Lilley

Barend Gehrels <bar...@xs4all.nl> wrote:

John Lilley

unread,
Feb 20, 2013, 5:03:38 PM2/20/13
to Barend Gehrels, boost...@lists.boost.org
Thanks, let me see if I understand.  It sounds like if I want a set of islands, some with lakes, that I should make each island a separate polygon, and each lake an inner ring within the polygon.  The overall set of islands would be a multipolygon, right?
 
Is multipolygon different than a vector of polygons like that returned by intersect()?
 
So if I just get a set of undifferentiated rings, it sounds like I need to determine which are contained by others and and combine them as inner/outer rings.
 
Once that is done can I intersect polygon against multipolygon or multipolygon against multipolygon easily?
 
--John Lilley

 

 

Reply all
Reply to author
Forward
0 new messages