Saturday 28 March 2015

Making perpendicular lines through each polygon edge using PostGIS?


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



Answer




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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...