[postgis-users] Inside / Outside of geography polygons

Darafei "Komяpa" Praliaskouski me at komzpa.net
Fri Aug 9 05:56:58 PDT 2019


Hi Christian,

To understand the query please try plotting your polygon on a globe and
then imagine axis aligned box that will contain it (one side parallel to
equator, other parallel to 0 and third to 90th meridian). You will see that
your "large" geometry is really 40 degrees wide spot around antimeridian.
To visualize it better using common planar GIS tools, feed it into
geography ST_Segmentize - it will produce the actual 'curved' geometry used
in calculation. To see closer to behavior you expect, make sure there are
no points connected by longer, not shorter, part of Great Circle, as in
your example.

Hope this helps.

On Thu, Aug 8, 2019 at 2:46 AM Christian Pschierer <
christian.pschierer at gmx.net> wrote:

> 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
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



-- 
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190809/d5f0fa07/attachment.html>


More information about the postgis-users mailing list