2

Is it possible to modify polygons (essentially, make them more complex by inserting additional points) so that their naïve point-linking rendering would be a closer match to their respective geodesic rendering?

Especially with such cryptic explanation, a picture is worth a thousand words...

enter image description here


Our use case is that we perform point-in-polygon outside PostgreSQL, by exporting the polygons, then performing PIP. The problem is that our PIP algorithm doesn't handle geodesics, therefore we'd like to be able to extract polygons from PostgreSQL which are closer to geodesic counterparts.

Note: no, for a myriad of reasons, we're not interested in doing PIP from inside PostGIS.

  • 1
    It's certainly possible; I've written such an implementation myself (though the basis is more properly by actual spheroidal distance than by delta longitude, which is seriously flawed). What have you tried? – Vince Jun 20 at 13:22
  • I have too in the past, but a native PostGIS option would save me some hassle :) – Jivan Jun 20 at 14:39
  • Agree on delta longitude being flawed btw – Jivan Jun 20 at 14:40
3

I think you can use ST_Segmentize to do this (especially if you have Geography objects).

Returns a modified geometry having no segment longer than the given max_segment_length. Distance computation is performed in 2d only. For geometry, length units are in units of spatial reference. For geography, units are in meters.

| improve this answer | |
  • I've tested it and it looks like even with a geography, it just fills the segments in a straight line, without respecting the geodesics. Did I do something wrong? – Jivan Jun 20 at 20:17
  • my bad! it actually does respect the geodesics, although it seems to do it for some polygons and not for others, even if I cast them as a geography – Jivan Jun 20 at 20:30
  • my bad... third and last. it does work!!! the polygons on which I thought it did not where in fact comprised of segments with many points across the same straight line. Great answer. – Jivan Jun 20 at 20:58

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.