2

I would like to do a real simple thing: I have a bounding box B1 (ST_MakeEnvelope) and I want to see if a square of 100 meters around a lat/long position intersects the other bounding box (B1).

I have tried to do this :

SELECT ST_Intersects(
        ST_MakeEnvelope(2.3400235176086426, 48.87195488537595, 2.3521900177001953, 48.86635145037327, 4326)::geometry,
            ST_Expand(ST_SetSRID(ST_MakePoint(1.888275146484375, 47.89788468044446), 4326)::geometry, 100));

This should return false, because the point position if more than 100 km from my B1 bounding box ...

But I always get :

 st_intersects
---------------
 t

Where is my mistake?


After @zimmi's answer I did :

SELECT ST_Intersects(
            ST_Transform(ST_MakeEnvelope(2.3400235176086426, 48.87195488537595, 2.3521900177001953, 48.86635145037327, 4326)::geometry, 3857),
                ST_Expand(ST_Transform(ST_SetSRID(ST_MakePoint(1.888275146484375, 47.89788468044446), 4326)::geometry, 3857), 100));

This works perfectly.

5

All EPSG:4326 geometries calculations are done with degrees instead of kilometeres. Use ST_Transform to reproject your data into a CRS that uses metric units.

  • Right, you expand by 100 degrees now. – user30184 Aug 19 '15 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.