5

I have a hand-digitized coverage stored in postgis. There, I have a few shiver-polygons I would like to get rid of by including them into one of the neighbouring polygons.

are there any commands that can be used to do that?

Something like

update coverage set the_geom=st_union(...) ...

Of cource, I want to use the attributes from the large polygon - I must be able t decide which way the union goes.

2 Answers 2

7

SQL:

UPDATE coverage SET the_geom = ST_Union(
(SELECT the_geom FROM coverage WHERE id = :polygon_id),
(SELECT the_geom FROM coverage WHERE id = :sliver_id)
)
WHERE id = :polygon_id;

Is that what You meant?

1
  • Looks good - if I just can use it to update the data set. I'll test it later today. Thanks! Commented Feb 5, 2013 at 9:30
4

First of all, You need to find a way to define what polygons are slivers, and what not.

Borrowing from here: Sliver triangle

slivers are usually defined by having much smaller area/volume than its circumcircle.

Secondly, for each sliver polygon You could run such algorithm: detect, if there is any polygon that overlaps/touches with the sliver polygon. If there are many that overlap, prefer the one that has biggest common area with sliver polygon; If none of polygons overlap with the sliver polygon, find the one that's exterior has biggest common length with sliver polygon's exterior. Like this You will find the polygon that You should connect the sliver to.

Then just update the polygon with ST_Union(polygon, sliver). However, if polygon and sliver polygon only have one point in common, then union of these two geometries would not be valid. (or it will be MultiPolygon).

Alternatively, see here: ArcGIS 10.1 - How Polygon Neighbouring Works This is interesting article on same topic.

3
  • I know exactly which polygons I want to get rid of, and I know which to merge them with. (the luck of having a not too big data set and a reasonably good person doing the digitizing...) - but anyhow, thanks for your info, I'll look it up. Commented Feb 5, 2013 at 8:46
  • Then You need help with forming the SQL of finding union of two geometries, provided You know the IDs of both geometries?
    – Rauni
    Commented Feb 5, 2013 at 9:08
  • That's correct, that what I tried to say in the original post ;-) Commented Feb 5, 2013 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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