I have polygons and lines I would like to make perpendicular lines through each polygon edge so I can find intersections with other polygons and lines.

enter image description here

  • 2
    Did you already tried something? if so please share your attempt so ppl. can help you better. In general, you are supposed to show your effort, when it comes for coding help – LaughU Aug 6 '17 at 11:44
  • 1
    Why not to use postgis.net/docs/ST_DWithin.htm? Tell more about what kind of features you would like to find? – user30184 Aug 6 '17 at 15:44

Assuming that you have PostGIS knowledge, this is one way forward:

  • Take the ExteriorRing from your polygon (results in a linestring)
  • Make seperate segments out of your ExteriorRing (use this example from Paul Ramsey)
  • Create parallel lines with ST_OffsetCurve with a desired distance D on the correct side (your polygons vertices should always have the same direction, use ST_ForceRHR when they don't)
  • For every segment, make a new line from the centroid of that segment to the centroid of the corresponding parallel line with ST_MakeLine

Now you should have your perpendicular lines with a length D starting from the sides of your polygon.

| improve this answer | |

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.