[postgis-users] Inside / Outside of geography polygons

Christian Pschierer christian.pschierer at gmx.net
Wed Aug 7 16:46:10 PDT 2019


Hi,

we found some unexpected results when doing spatial queries on very
large geography polygons. For example

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(160,
60),ST_Point(-160,-60)), 4326)::geography,ST_SetSRID(ST_Point(0, 0),
4326)::geography)/1000

returns 13130km instead of 0 as the point 0,0 should be inside this polygon.

Queries on smaller search areas, or geometry queries return 0.

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(60,
60),ST_Point(-60,-60)), 4326)::geography,ST_SetSRID(ST_Point(0,
0),4326)::geography)/1000

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(160,
60),ST_Point(-160,-60)), 4326),ST_SetSRID(ST_Point(0, 0), 4326))/1000

It seems like PostGis switches inside/outside on geographies if they
exceed a certain size. Is this correct? Is there a way to control this
behaviour?

Greetings
Christian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190808/a2c5a4cb/attachment.html>


More information about the postgis-users mailing list