[postgis-users] ST_Difference Syntax
robe.dnd at cityofboston.gov
Mon Oct 22 13:39:20 PDT 2007
How have you failed? Did you get an error or some unexpected result.
ST_Difference takes as input 2 geometries - ST_Difference(geom1, geom2)
and returns that portion of geom1 that is not in geom2.
I generally use it in conjunction with intersection. If 2 geometries
are Disjoint - do not intersect then ST_Difference returns just geom1 I
believe which is not terribly interesting and a bit of a waste fo
processing speed since there are easier ways to return that.
So you would use it something like this - for example if you wanted to
know that portion of a land parcel that is not built on, then you would
do something like
SELECT ST_Difference(l.the_geom, b.the_geom)
FROM parcels l INNER JOIN buildings b ON ST_Intersects(l.the_geom,
Note here I am making the wrong assumption that only one building lies
on a parcel - so this example is a bit flawed (but simpler than my real
query), but hopefully will give you an idea of how it is used.
Note: There is the less popular ST_SymDifference(geom1, geom2) that
returns that portion of geom1 + geom2 that is not shared. Thus it is
called Symmetric Difference since the order of the arguments does not
Hope that helps,
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Richard Heimann [C]
Sent: Monday, October 22, 2007 3:47 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] ST_Difference Syntax
I have failed at constructing the ST_Differnece operation. Can someone
expose the proper syntax? Thanks
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users