I am trying to dissolve polygons based on a column type using PostGIS 10.4. I am pre-compiling tables, so time requirements are not really an issue. ST_Union does almost everything that I want straight out of the box. However, the ST_Union is has left lots of artifact lines inside the polygon as seen in the pictures below. Is anyone aware of a way to remove the lines inside the polygons? I am not sure if there is a better way to make the union call or rather to clean the polygons up after the union.

INSERT into new_table (count_field, geom) SELECT count_comp, ST_Union(geom) as geom FROM old_table GROUP BY count_field; enter image description here

  • 2
    I'd say that's most likely due to small gaps between those polygons, i.e. a topology issue.
    – geozelot
    Jun 16, 2018 at 7:36
  • if this indeed are tiny gaps and holes, it's a little tricky to get them out while preserving those inner rings you want. you could first check your dissolved polygons with ST_NumInteriorRings and see if they have plenty. you can get the outer ring as linestring with ST_ExteriorRing or a set of all rings with ST_DumpRings (use ST_MakePolygon with either to get back polygons). this get's more complicated if any of those rings are invalid. see this excellent blog on the topic.
    – geozelot
    Jun 16, 2018 at 9:58
  • 1
    Possible duplicate of Deleting small gaps (slivers) between polygons? Jun 17, 2018 at 1:49
  • 1
    I have seen this a lot and it can be solved by doing a small positive buffer, ST_Buffer(geom, x) before ST_Union and then reverse this after with ST_Buffer(geom, -x). You could also try using ST_SnapToGrid on the input polygons. It is likely to be cause by minor precision issues or small gaps as @ThingumaBob pointed out. Jun 17, 2018 at 11:07
  • @JohnPowellakaBarça +1 for simplicity ,)
    – geozelot
    Jun 17, 2018 at 11:55

2 Answers 2


After following advice from tThingumaBob and JohnPowellakaBarça, I was able to remove the slivers. ST_NumInteriorRings, ST_ExteriorRing, ST_DumpRings didn't work for me, but ST_Buffer() did.
Just for reference, if anyone else is working at the parcel level scale, the x value that ended up working for me was 0.00001. So my final query was INSERT into new_table (count_field, geom) SELECT count_field, ST_Buffer(ST_Union(ST_Buffer(geom, 0.00001)), -0.00001) as geom FROM old_table GROUP BY count_field;

Thanks for everyone's help


Have you tried to st_snap polygon to each other with ST_Snap?

  • 1
    Welcome to GIS StackExchange! Please take a moment to take the tour to learn about our focused Q&A format. For answers, we are looking for more than just a short sentence/question -- please edit your answer to elaborate on why you think this will work. As you gain reputation you will be able to comment on questions, which can be used to ask for clarification.
    – smiller
    Oct 26, 2018 at 16:13

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.