I run following code in PostGIS. Both SRID is default, which is 4326.

select ST_Intersects('POINT(104.042455 30.657381)'::GEOGRAPHY(POINT), ST_MakeEnvelope(80, 30, 140, 40, 4326)::GEOGRAPHY(POLYGON))

'POINT(104.042455 30.657381)'::GEOGRAPHY(POINT): This represents a point geography object with longitude 104.042455 and latitude 30.657381.

ST_MakeEnvelope(80, 30, 140, 40, 4326)::GEOGRAPHY(POLYGON): This creates a rectangular polygon (bounding box) with the specified corner coordinates (80,30), (140,40) in the WGS 84 coordinate system (SRID 4326). The rectangle spans from longitude 80 to 140 and latitude 30 to 40.

The point (104.042455, 30.657381) is within the longitude range (80 to 140) and the latitude range (30 to 40) of the bounding box.

Given this, the query should logically return true since the point is clearly within the bounds of the specified rectangle.

But, following return true:

select ST_Intersects('POINT(108.963413 34.284203)'::GEOGRAPHY(POINT), ST_MakeEnvelope(80, 30, 140, 40, 4326)::GEOGRAPHY(POLYGON))
  • What if you prefix your point string with SRID=4326;? Or if you use ST_GeographyFromText instead of the ::? Dec 31, 2023 at 8:46
  • The result is the same.
    – timewalker
    Dec 31, 2023 at 12:33

2 Answers 2


Because when PostGIS handles geography objects it converts them into a local UTM zone and then uses Cartesian maths. In this case your point doesn't fall inside the polygon.

enter image description here

If you want it to then you need to densify your polygon so that the edges bend with the projection.

enter image description here

In PostGIS you need to use the ST_Segementize function.

  • Thanks. Actually, I am implementing a tile API. Would you please help on this question? Thanks gis.stackexchange.com/questions/473566/…
    – timewalker
    Dec 31, 2023 at 14:34
  • 1
    With all respect, st_intersects is computed in geography directly, there is no conversion to UTM (or other "best" coordinate system) (code)
    – JGH
    Jan 2 at 21:10

Your statement "ST_MakeEnvelope(80, 30, 140, 40, 4326)::GEOGRAPHY(POLYGON): This creates a rectangular polygon (bounding box)" is false. It is not a square because it has been casted to geography.

When using geography, a line connecting two points is not a straight line but rather a great circle line.

The coordinate of the point is slightly above the southernmost latitude, but since it remains below the great circle line, st_intersects is false.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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