I have a set of points defined by their longitude and latitude, and I would like to check if they lie within a "polygon" on sphere. By polygon on sphere, I mean area in between 4 lines going between 4 points that I have. As I understand it, Polygon will give me straight lines that are cast onto a sphere, and I want arcs that are the shortest possible connections between the points. So how may I do that? edit: by do that, i mean this:

SELECT * FROM ST_Distance(ST_GeographyFromText('POLYGON((70 -40,70 -39,71 -39,71 -40,70 -40))'), ST_GeographyFromText('POINT(70.48 -39)'), False)

should return 0, because the POINT lies on the boundary arc. I'm using postgresql 9.4 with postgis 2.1.8

  • Since you have tagged this with "postgis", I'm assuming you want the question answered in that context, but it wouldn't hurt to edit the question to specify which versions of PostreSQL and PostGIS you are using, and that you're looking for an SQL solution. – Vince Dec 16 '15 at 16:21
  • 1
    I think that the answer to your previous question gis.stackexchange.com/questions/173995/… answers this too. Straight lines cast onto a sphere will become arcs and you can handle the case with geography. – user30184 Dec 16 '15 at 16:51

As per user30184's answer in this topic: If you have polygon as geography, the shortest path from one corner to another is an arc on the surface. Your polygon edges do not go underground. Your real mistake is to think that the shortest arc from POINT (70 -39) to POINT (71 -39) will follow the -39 latitude. So there is no real answer, my question is just wrong. Thank you user30184! Imagining things in 3D is hard:)

Your Answer

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

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