1

I have strange thing happening in postgresql DB. I would like to understand what is the major difference between using st_equals and using the equals (=) sign ex :

SELECT * FROM x WHERE st_equals(the_geom, st_astext('POINT(962952.534 6469066.353)'));

and

SELECT * FROM x WHERE the_geom=st_astext('POINT(962952.534 6469066.353)');

An this code will not be the same as

SELECT * FROM x where st_geohash(st_transform(the_geom, 4326))=st_geohash(st_astext('POINT(962952.534 6469066.353)'));

and not even the same as

SELECT * FROM x WHERE st_astext(the_geom)=st_astext('POINT(962952.534 6469066.353)');

I would like to understand why the result of these request differ

EDIT: so this question was mark as duplicate, I didn't found this post about st_equals and equal sign at the time. About converting to text with st_astext I was thinking about losing precision may cause the difference. But about st_geohash ?

3
  • 3
    ST_Equals — Returns true if the given geometries represent the same geometry. Directionality is ignored. While equal is a Comparison Operator. Commented Oct 16, 2017 at 19:00
  • My guess would be that comparing geometrics “could” have different result than comparing if two statements are equal (with the equal comparison Operator). Can’t go further since I don’t have experience with your direct issue Commented Oct 16, 2017 at 19:11
  • Comparing geometries after casting them to text is for sure inaccurate because of inaccuracy of floating point conversions. Another thing is that "=" and "ST_Equals" just are not the same. You will find many old questions dealing with this, including gis.stackexchange.com/questions/223342/….
    – user30184
    Commented Oct 16, 2017 at 21:34

0

Browse other questions tagged or ask your own question.