[postgis-users] what does it really mean for one geometry to be equal to another

Sandro Santilli strk at kbt.io
Thu Sep 15 22:11:55 PDT 2016


On Thu, Sep 15, 2016 at 08:53:25PM -0500, Rhys A.D. Stewart wrote:

> Now I'm just confused, the 2 premises have the same st_astext, but
> different wkb representations and as such are not being caught in the
> st_equals call.
> 
> Is there some gotcha that I don't know about, maybe something in the docs
> that I missed or is this not supposed to happen?

What you describe is expected:
the text representation is approximated/truncated.

You could create your index on ST_AsBinary(geometry) if you wanted
to check binary-level equality, but as your subject asks: what's
your concept of equality ? Do you really want those practically
identical points in your db ? Or you could create an index on
ST_SnapToGrid(geom, <tolerance>), for points to be no closer
than <tolerance>. Or (for lines) you could use ST_HausdorffDistance.

Many ways to interpret equality, which is why the equality operator
is currently just checking for approximated minimum bounding box equality
(probably still equal for your two almost-identical points).

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   https://strk.kbt.io/services.html


More information about the postgis-users mailing list