3

I have a multipolygon with two parts:

enter image description here

I want to erase the line that separate both parts and get a single polygon that looks like this:

enter image description here

I don't mind if I do it in QGIS or in Postgis, but it has to be only for this multipolygon.

I have read similar posts that suggest a solution to the problem but I had no success so far. I read and tried this, this and this.

I tried postgis functions like ST_Dump, ST_Collect, ST_ConvexHull, St_Union, ST_ExteriorRing, ST_Boundary, etc in SQLs like:

update my_table set the_geom = ST_Boundary(st_snaptogrid(the_geom,0.0001))  where id=3173

I don't really know which is the right approach to achieve this.

PD: If I do ST_NumGeometries I obviously get 2 geometries.

Egidi
  • 3,738
  • 3
  • 30
  • 55
  • 2
    It is not topologically possible to have a valid multipolygon with shared boundaries between parts. You may have a collection. – Vince Feb 24 '17 at 12:33

1 Answers1

3

It's a kind of hack but you can use ST_Buffer(geom,0)...

Proof of concept:

select 1 as id,
   ST_astext(ST_Buffer(ST_Geomfromtext('MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)),((1 0,1 1,2 1,2 0,1 0)))'),0)) as way

id way

1 POLYGON((0 0,0 1,1 1,2 1,2 0,1 0,0 0))

Jendrusk
  • 2,617
  • 9
  • 16