[postgis-users] How to tell if 2 geometries are spatially equal
Obe, Regina
robe.dnd at cityofboston.gov
Fri May 30 13:16:06 PDT 2008
I recall this having come up before. I always thought that ~= would
tell me if 2 geometries are spatially equal but it doesn't seem to.
The only way I can figure to determine spatial equality is if
ST_Within(A,B) And ST_Within(B,A) (or ST_Difference(A,B) AND
ST_Difference(B,A) both return an empty geometry collection)
--So case in point
SELECT geom1 ~= geom2 as what, ST_Within(geom1, geom2) AND
ST_Within(geom2, geom1) As spatial_equal,
ST_AsText(ST_Difference(geom1, geom2)) as diffgeom12,
ST_AsText(ST_Difference(geom2, geom1)) as diffgeom21
FROM (SELECT 'LINESTRING(1 1, 1 2, 1 3)'::geometry As geom1,
'LINESTRING(1 1, 1 3)'::geometry As geom2) As foo
Results:
what | spatial_equal | diffgeom12 | diffgeom21
------+---------------+--------------------------+----------------------
----
f | t | GEOMETRYCOLLECTION EMPTY | GEOMETRYCOLLECTION
EMPTY
Is there a function / operator that does that (also what does geom1 =
geom2 compare - is it just bounding boxes or is that the spatially equal
operator I am looking for?)
Thanks,
Regina
-----------------------------------------
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.
More information about the postgis-users
mailing list