[postgis-users] How to fix not valid polygons?
Stephen Woodbridge
woodbri at swoodbridge.com
Sun Dec 18 11:50:22 PST 2005
OK, so now I need to take a step backwards since some of the polygons I
have are not valid. I am wondering how I might go about deconstructing a
(multi?)polygon into a set of line segments that can be passed to
polygonize() along the lines of:
insert into newtable select a, b, ..., polygonize(deconstruct(the_geom))
from oldtable;
This is not quite what I want because polygonize() returns a collection
and what I really want is a row for each polygon with the attributes of
the original.
So the deconstruct() function could probably be implemented by using
dump() to simplify collections and multipolygons into polygons, then
extracting the polygon or polygon rings, getting the points from each of
these and then generating linestrings based on adjacent pairs and then
returning the lot of them as a set to be consumed by polygonize().
The only problem is I do not see any way to do this short of mangling
the text of the astext() representation of these.
npoints() will tell me how many points are in the polygon, but
num_points() and pointn() only work on linestrings.
It would be nice to have some documentation on object deconstruction.
Anyway, is this the best approach? Do you see problems with this
approach? What are my other options? getting good polygons to start with
does not appear to be an option at this point.
-Steve
More information about the postgis-users
mailing list