ARC/INFO Functions – UNION

We are going to conclude our overlay posts with the ARC/INFO UNION command.  This should be a lot easier than it actually is.  I think the problem is that Manifold may have a bug in the ClipSubract command.  What I discovered was that the ClipSubract clause only seems to work on the first geometry in a layer.  With that error, it would appear that we are dead in the water.  However, if Manifold’s ClipSubract only works on the first geometry, well, we can manipulate the query to pass ClipSubract a single geometry.  To do that, we use the UnionAll command to take all the geometries in one layer and union them together into a single geometry.

So, the ARC/INFO UNION command in SQL needs three things:

1.  The intersection of the two layers (to get the intersection of the two layers)
2.  The clipsubtract of layer 1 and layer 2 (to get the part of layer 1 not intersecting layer 2)
3.  The clipsubract of layer 2 and layer 1 (to get the part of layer 2 not intersecting layer 1)

But, we are still not out of the woods yet.  We need to attach the attributes to the layers. To do that, we have to fake out Manifold a little to think that we actually have a unique ID for the the subtract layer.  The ClipSubract clause correctly clips the geometries, but it will not return the ID for the subtract layer since we UNIONEDed the entire thing into a single geometry.  So, to fake Manifold out, we return a value of 0 as the id field for the layer.

  SELECT ClipIntersect(, AS g, AS cid, AS rid
  FROM circle, rectangles
 SELECT Clipsubtract(circle.[Geom (I)],(SELECT UnionAll(id) FROM rectangles)) AS g, AS cid, 0 AS rid
 FROM circle
 SELECT ClipSubtract(rectangles.[Geom (I)],(SELECT unionall(id) FROM circle)) AS g, 0 AS cid, AS rid
 FROM rectangles
LEFT JOIN [circle] ON = cid
LEFT JOIN [rectangles] ON = rid

4 thoughts on “ARC/INFO Functions – UNION

  1. Hi Art, yes I think there is a bug in the ClipSubtract function in that it does not return polygons from the layer to be clipped which are disjoint with the 2nd layer. However, the ClipSubtract function does appear to work on more than 1 geometry as long as the polygons touch. For example, if there are 3 rectangle in the rectangle layer with 2 of the rectangles overlapping the circle in the circle layer and 1 rectangle which is disjoint then the following query will return the 2 rectangles clipped to the circle but will not return the rectangle which does not overlap the circle:
    ClipSubtract(rectangles.[ID], circle.[ID]) as g
    FROM [rectangles] INNER JOIN [circle]
    on Touches (rectangles.[ID], circle.[ID]);

    • Just a correction to my previous post: I meant to say “the query returns the 2 rectangles with the circle area clipped out, but will not return the rectangle which does not touch the circle (the disjoint rectangle).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s