1

Consider the following geographic polygon in PostGIS:

POLYGON((60 -60,60 -50,179 -50,179 -60,60 -60))

The smallest latitude is -60, so initially I expected any point with a latitude less than -60 to fall outside of the polygon.

But it doesn't; a point at 136,-73 is considered to fall within the polygon:

SELECT ST_Covers(ST_GeogFromText('SRID=4326;POLYGON((60 -60,60 -50,179 -50,179 -60,60 -60))'), ST_GeogFromText('SRID=4326;POINT(136 -70)'));

returns true.

After some thinking, I realised that this is because PostGIS uses great circles to form the edges of polygons, and in this case, that makes the lower edge of the polygon 'bulge out' towards the south pole.

If I view the same polygon in Google Earth, the lower edge of the polygon runs along the -60 degree parallel, so apparently Google Earth uses a different manner to connect vertices than PostGIS.

What is the name of the manner that Google Earth uses, and can I somehow make PostGIS use that same manner?

  • I see that the term I'm looking for is probably a Rhumb line. So, is there any way to make PostGIS use rhumb lines to connect vertices of polygons? – Jeroen Sep 18 at 15:07
  • Please Edit the question to provide clarifications. – Vince Sep 18 at 15:30
  • try: ST_GeomFromText... – Cyril Sep 18 at 16:23
  • 2
    as @Cyril pointed at, PostGIS does so for it's GEOGRAPHY type; it's meant to do that. if you use a planar representation (or projection) using the GEOMETRY type, you will get your falsey result. – ThingumaBob Sep 18 at 16:51
  • @cyril That does work, but if I try the same query to see if the south pole falls within a polygon around the south-pole (on the -60th parallel, for instance), that succeeds using geography types, but it fails with geometry types -- which makes sense, since geometry types essentially use Mercator projection. – Jeroen Sep 19 at 11:31

Your Answer

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

Browse other questions tagged or ask your own question.