Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repair a polygon with self-intersection?

Is there a way to remove self-intersections from a polygon using GEOS?

like image 258
Alexander Avatar asked Nov 24 '10 14:11

Alexander


People also ask

Can a polygon intersect itself?

A polygonal boundary may be allowed to cross over itself, creating star polygons and other self-intersecting polygons.

How do you intersect a polygon?

Polygons can intersect in three ways: Overlap—Area of overlap can be produced by leaving the Output Type to its default value (LOWEST). Common boundary/touch at a line—This type of intersection can be produced by specifying LINE as the Output Type.

How do you fix an invalid polygon?

Repairing invalidity involves stripping a polygon down to its simplest structures (rings), ensuring the rings follow the rules of validity, then building up new polygons that follow the rules of ring enclosure.

What is a self-intersecting line?

If a feature intersects itself at a point and continues by crossing itself, it is considered a self-intersection.


1 Answers

So, I have to answer the question myself. Maybe it will help someone.

You can repair a polygon using the geos::operation::buffer::BufferOp class. E.g.

geos::geom::Geometry * result = 
                       geos::operation::buffer::BufferOp::bufferOp(polygon, 1.0);

You can find some more good recipes in the Secrets of the JTS Topology Suite.

like image 53
Alexander Avatar answered Oct 03 '22 14:10

Alexander