[postgis-users] How to tell if 2 geometries are spatially equal

Dylan Beaudette dylan.beaudette at gmail.com
Mon Jun 2 13:36:46 PDT 2008


how about "polygons sharing(?) / having(?) co-linear line segments"?

On Monday 02 June 2008, Martin Davis wrote:
> I use "topologically equal" because the OGC SFS specification uses the
> term "topology" extensively in their discussion of the meaning of the
> DE-9IM model, on which the semantics of ST_equals is based.
>
> I can see how you might want a definition of topology which would
> distinguish the two given geometries.  However, I think that the DE-9IM
> is based on the idea of simplicial complexes.  I'm fairly certain that
> two geometries are only comparable in this model if they can be
> expressed in the same simplicial complex.  In such a setting, both of
> the geometries in question will have the same form - and hence are
> equal.  I'm pretty sure that simplicial complexes are an aspect of
> topolgical theory - which brings us back to where we started.
>
> I don't like the term "spatially-equal", because I think "spatially" is
> too vague and overloaded.  How about "point-set equal"?  The idea is
> that  A = B iff every point of A is in B and every point of B is in A.
>
> Andy Anderson wrote:
> > I wouldn't call this example "topologically" equal; one has two
> > vertices and the other has three, and that's the only characteristic
> > that's relevant in topology (not even their positions :-)
> >
> > "Coincident" is probably a better term, though "spatially equal" is
> > probably just as good, and contrasts well with the term "geometrically
> > equal" that the manual uses to describe the ~= operator.
> >
> > -- Andy
> >
> > On May 30, 2008, at 7:54 PM, Martin Davis wrote:
> >> Will ST_equals do what you want?  It reports whether two geometries
> >> are topologically equal.
> >>
> >> (So for example, ST_equals('LINESTRING(0 0, 10 10)','LINESTRING(0 0,
> >> 5 5, 10 10)') is true)
> >>
> >> Obe, Regina wrote:
> >>> 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.
> >>>
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >> --
> >> Martin Davis
> >> Senior Technical Architect
> >> Refractions Research, Inc.
> >> (250) 383-3022
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341



More information about the postgis-users mailing list