[postgis-users] Problem in Polygon-to-Polygon Intersection
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Feb 14 19:24:00 PST 2007
Myunghwa Hwang wrote:
> Hi, list!
>
> I have a problem in the results of intersection function.
> I have two polygon boundary of a same area for 1990 and 2000,
> and what I want to get is not just an common part but 1990 boundary
> whose polygons are split by 2000 Boundary,
> like the result of ArcToolbox's Union.
>
> I used the following query:
> Create Table tb_name with oids as
> select intersection(a.the_geom, b.the_geom)
> from bnd_1990 a, bnd_2000 b
> where intersects(a.the_geom, b.the_geom);
>
> The problem is the results is missing some minor parts, generating holes
> in the entire boundary.
> Through some tests, I figured out the missing parts are type of
> geomertycollection.
> I tried to get right intersected polygon by using GeometryN().
> But some geometries in a geomertycollection were line, not polygon.
>
> Anybody can tell me how I can get the result from ArcToolbox's Union?
> or how I can avoid the geometrycollection problem?
You can't avoid the geometrycollection, but you can work around it like
this:
update yourtable set the_geom =
(select geomunion(geom1) from
(select (dump(the_geom)).geom as geom1) as foo
where geometrytype(geom1)='POLYGON'
)
where geometrytype(the_geom)='GEOMETRYCOLLECTION';
This will create a new polygon the is the union of the polygons in the
collection and throw out the points and lines.
Give it a try.
-Steve W.
> Thank you in advance.
>
> from Myunghwa Hwang_______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list