3

The clipper lib has an amazing function to create a strictly simple polygon (definition below).

Is it possible to do this in simple features (pref postgis or shapely)?

A strictly simple polygon is a simple polygon that does not contain 'touching' vertices, or 'touching' edges.

http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Properties/StrictlySimple.htm

  • What would be the input? If vertices touch, what should happen? Perhaps to get a multipolygon instead of non-simple polygon, or? – user30184 May 24 '17 at 20:10
  • @user30184 yes one with holes prob – DaynaJuliana May 25 '17 at 3:43
  • duplicate of Stricly simple function-Shapely – gene May 25 '17 at 11:00
3

With PostGIS use ST_MakeValid http://postgis.net/docs/ST_MakeValid.html

An example about self-touching ring:

enter image description here

SELECT ST_AsText(ST_MakeValid(ST_GeomFromText('
POLYGON (( 280 580, 400 580, 280 480, 400 480, 400 360, 280 360, 280 480, 280 580 ))')));

Result:

MULTIPOLYGON(((280 480,400 480,400 360,280 360,280 480)),((280 580,400 580,280 480,280 580)))

Ring makes a hole

enter image description here

SELECT ST_AsText(ST_MakeValid(ST_GeomFromText('
POLYGON (( 280 580, 380 580, 380 500, 320 540, 320 460, 380 500, 380 440, 280 440, 280 580 ))')));

Result:

POLYGON((280 580,380 580,380 500,380 440,280 440,280 580),(380 500,320 540,320 460,380 500))
  • Wouldn't this not handle the touching edges case ? – DaynaJuliana May 25 '17 at 3:43
  • Please provide test cases as WKT. – user30184 May 25 '17 at 9:44
  • How would this be done in shapely? Thanks for the postgis result btw ! – DaynaJuliana May 29 '17 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.