TransWikia.com

Postgis intersection behaves strangely when getting closer to poles

Geographic Information Systems Asked by Alvin Sartor on May 1, 2021

We use Postgis for Django to locate the objects inside a certain viewport. It works great at the equator, but the farther we move, the more distorted the viewport becomes.

Here is the result (the red line shows the "ignored area"):

enter image description here
enter image description here

Same on the southern hemisphere:
enter image description here

We retrieve the viewport from Maps, build a Polygon and intersect it with the coordinates of the objects:

viewport = Polygon.from_bbox((southeast_lng, southeast_lat, northwest_lng, northwest_lat,))
result = queryset.filter(coordinates__intersects=viewport)

The coordinates field in the object are defined as following:

coordinates = models.PointField(_('Coordinates'), srid=4326, null=True, geography=True)

Additional info:

  • The "missed area" depends on zoom level and vicinity to the pole
  • Setting geography=False fixes it! But then we have problems at the 180th meridian.

Does anyone know what might be causing this?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP