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.

3
  • 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
    Commented Jun 20, 2020 at 13:22
  • I have too in the past, but a native PostGIS option would save me some hassle :)
    – Jivan
    Commented Jun 20, 2020 at 14:39
  • Agree on delta longitude being flawed btw
    – Jivan
    Commented Jun 20, 2020 at 14:40

1 Answer 1

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.

3
  • 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
    Commented Jun 20, 2020 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
    Commented Jun 20, 2020 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
    Commented Jun 20, 2020 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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