I have a conservation dataset that im trying to simplify for the purpose of using it as a GML layer in openlayers, ie reducing the total shape and node count to quite small.

The data has issues: eg-

  • about 15K orig polygons of which i only need the 500 largest post dissolve.
  • overnoded, way too detailed
  • lots of long thin slithers either inside or outside the main polygons which im not that interested in
  • hundreds of invalid geometrys, rings with less than three points, self intersections etc

Using this as an exercise whats a good way to clean and simplify a dataset like this?

Ive been trying variations on this so far:

  • st_simplifypreservetopology,10, to reduce time taken below
  • hand fix invalids
  • buffering +20m to swallow the internal slithers,
  • st_union, trys ot make single feature, mem exhausts usually
  • unbuffering 40m, to swallow external slithers.
  • st_union,
  • buffer +20 to return to right area.
  • st_simplify,10
  • st_dump
  • bin any with area less than 1000ha

Its slow and simplify always creates yet more invalid shapes.

A subquestion is how to make postgis do the equivalent of qgis 'buffer and dissolve', ie merge shapes that adjoin or overlap, but leave other shapes as seperate features.

1 Answer 1


To delete invalid geometries:

DELETE FROM table WHERE NOT ST_isvalid(the_geom);
  • Except most of the invalid geometrys have the main polygon correct (which we clearly need) but with lots of invalid interior rings. Sometimes as many as 200. Im guessing that they are a result of a previous brain dead simplification, after all what kind of thing leaves rings with only 2 nodes? And rings with three or more nodes in a straight line? And... non ring parts interior to another non ring part.
    – Peter
    Sep 27, 2011 at 21:17
  • 2
    Which gives me an idea is there a way to remove rings or polygon parts that have zero area?
    – Peter
    Sep 27, 2011 at 21:21

Your Answer

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

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