[postgis-users] Cleaning non valid multipolygon

Yves Moisan yves.moisan at boreal-is.com
Mon Feb 2 11:00:18 PST 2009


Hi All,

I have some data from an AutoCAD file (dwg) for which some of the
multipolygon elements are not valid geometries.  The pattern is pretty
simple : some polygons display the origin vertex 3 times as though one
started digitizing going clockwise to close the polygon and then came
back counterclockwise not necessarily exactly on the same vertices and
closed again.  An example :

"MULTIPOLYGON(((
376249.7830234 8717655.6050357,
376268.0818048 8717666.0116082,
376265.2666038 8717670.5117466,
376247.812391 8717660.3864341,
376249.7830234 8717655.6050357,
376247.812391 8717660.3864341,
376265.2666038 8717670.5117466,
376268.0818048 8717666.0116082,
376249.7830234 8717655.6050357)))"

Deleting the last 4 lines on that geometry and shoving it back in does
the job.  I tried to find an automated way of doing this (buffer,
st_geometry ...) and but didn't find anything.  Any pointer to an
automated way of doing that, short of writing my own function, which I
would need pointers for examples too :-),

TIA,

Yves Moisan




More information about the postgis-users mailing list