2

How can you determine the orientation of a PostGIS geography polygon? I'm looking/hoping for a function that would tell me which side is the interior (left or right) as you traverse the vertices of the outer shell in order.

I have seen the ST_Orientation function, but it only works for geometry. I have also seen the ST_ForceRHR and ST_ForceLHR functions. But again, they only work for geometry.

I have data that wraps around the poles, so naive casting to geometry won't work for me. (Or at least I don't think so. Maybe this isn't true.)

I'm a reasonably good programmer, so if no such function exists then an algorithm outline would be fine too.

  • A reliable algorithm is not possible, because polylines on the sphere merely divide it into two pieces; neither one of them is distinguished (the way the infinite component in the plane would be). Let's hope an accessible orientation property is stored with the polygon. – whuber Aug 26 '14 at 22:47
  • @whuber: If I remember correctly, PostGIS defines the interior to be the "smaller" of the two pieces of the sphere(-oid). (And that happens to work for me... none of my polygons cover more than half the sphere.) Though I can't seem to find a reference to that fact any more. And I don't see a way to find out which side that represents. – csd Aug 27 '14 at 13:52

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.