[postgis-users] Merge function in PostGIS
Bruce Rindahl
rindahl at lrcwe.com
Mon Oct 30 12:50:26 PST 2006
I need a merge function in PostGIS. What this means is if I have a
multipolygon and if any two parts share a common edge I need the union of
the two parts in one polygon. For example if I have:
MULTIPOLYGON(((partA)),((partB)),((partC))) where partA and partC intersect
or share a common edge, the result will be:
MULTIPOLYGON(((Union of partA & partC)),((partB)))
I know it can be done via the following:
Get the number of polygons via NumGeometries();
For each part (obtained via GeometryN()), loop through all the other parts
and check if NumGeometries(GeomUnion(partA,partB)) = 1.
If it does, replace partA with GeomUnion(partA,partB) and drop partB.
Continue until all the parts are checked.
Before I start on this - Has someone already done this? Is there a better
way?
Thanks
Bruce Rindahl
More information about the postgis-users
mailing list