[postgis-users] UNION

RAVI KUMAR ravivundavalli at yahoo.com
Mon Sep 17 06:03:44 PDT 2007


Hi Regina,
  giving the link to show actual how the UNION of polygons is not working as per expectation.
  Please see the clips in the link.
   
    CREATE TABLE abc(code smallint, info smallint) with oids;
  SELECT AddGeometryColumn('public', 'abc', 'the_geom', 4326, 'MULTIPOLYGON', 2);
   
  --The insert
   
  INSERT INTO abc(code, info, the_geom)
    SELECT newtb.code,  newtb.info, geomunion(newtb.cgeom) as thenewgeom
  FROM 
  (  SELECT a.code, b.info, geomunion(a.geometry, b.geometry) as cgeom
      FROM a
          INNER JOIN b ON a.geometry && b.geometry AND intersects(a.geometry, b.geometry)
      UNION ALL
      SELECT a.code, null As info, a.geometry as cgeom       FROM a 
          LEFT JOIN b ON a.geometry && b.geometry AND intersects(a.geometry, b.geometry)

          WHERE b.geometry IS NULL
      UNION ALL
      SELECT null as code, b.info, b.geometry as cgeom
              FROM b LEFT JOIN a ON a.geometry && b.geometry AND intersects(a.geometry, b.geometry)
             WHERE a.geometry IS NULL
  )  AS newtb
  GROUP BY newtb.code, newtb.info


   
  May be I should be using different syntax for such a result.
   
   
  http://www.kodakgallery.com/I.jsp?c=cjns10h3.8ovw4dsn&x=0&y=w3kbw0 
   
  Ravi Kumar

       
---------------------------------
Catch up on fall's hot new shows on Yahoo! TV.  Watch previews, get listings, and more!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070917/11e32dcc/attachment.html>


More information about the postgis-users mailing list