2

It feels like I've been struggling with this 'simple' problem for years, hopefully it is just a noob mistake..

We are using Postgis to facilitate an interface we wrote to do spatial editing, like splitting. When I split a polygon with a linestring, in this example below, the two returned polygons are smaller and creates holes between them and the touching features. As I gathered from other posts, it is due to 'rounding' within st_split - if anyone can confirm?

enter image description here

In this example, it creates a very small hole shown with the black line.

enter image description here

This shouldn't be a problem, because I figured I can just snap the splitted feature to the touching feature or exterior ring of original or, or.. But it doesn't seem like snapping does anything, the original wrong polygons is returned - I tried different snapping tolerances as well.

What I've tried: Straight forward split: Holes created with touching features Iterate through splitted polygons, snapping using different approaches. -snap to exterior ring. -snap to the union of exterior ring and the other splitted polygon. -snap to the union of touching features and the other splitted polygon. All resulted in the same holes, doesn't seem like snapping made any changes. I even tried not using the splitted polygon, but to make a polygon using the difference of the original polygon and the other splitted polygon - but this obviously created unwanted slivers added to the result. Even upgraded from postgis 2.4.4 to 2.5.3, hoping it was a postgis bug.

My end goal is simple, I need to split a polygon with a linestring, and the resulted polygons shouldn't create holes/overlaps with its neighbouring features. But with st_split and/or st_snap, I'm just not getting it right.. Either I'm doing it wrong, or somebody had the same issue and resolution.

EDIT: Example:

Main Polygon that needs to split:

'POLYGON((808369 1000106,808344 999973,807912 999980,807753 1000472,807882 1000643,808409 1000419,808469 1000393,808369 1000106))'

Splitting linestring:

'LINESTRING(807765.0170035374 1000047.1389691661,808173.4773734363 1000627.5826527067)'

Touching features to main polygon:

'POLYGON((808273.979982937 999453.309405212,806977.263634936 999559.01997706,807034 999718,807120 999959,807532 1000288,807742 1000457,807753 1000472,807912 999980,808344 999973,808279 999628,808273.98 999453.31,808273.979982937 999453.309405212))'

'POLYGON((808267 999210,808273.979982937 999453.309405212,808273.98 999453.31,808279 999628,808344 999973,808369 1000106,808469 1000393,808475 1000391,808615 1000065,808618 999395,808620 998905,808640.709074031 998823.783631442,808408.592759303 998769.168027977,808321.474272447 998748.671005211,808267 999210))'
  • 2
    It would help a lot if you could provide the original polygon, the split polygons, and the adjacent polygon as WKT. Split should not make polygons smaller. It should only create a new vertices at crossings. The vertices which were already in the original polygon should remain the same. However ST_Snap may change the original coordinates as well. But what I think you should do is to edit the adjacent polygon by the same when you split the other polygon by inserting a new vertex into the common border at exactly same coordinates. Borders can match exactly only when they have same vertices. – user30184 Nov 9 at 10:57
  • @user30184 I was just busy editing it with the examples. I did not think of that, I will try it and report back - it makes sense why the snapping wasn't working. – Sagariouz Nov 9 at 11:28

Your Answer

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

Browse other questions tagged or ask your own question.