Wednesday 23 December 2015

polyline creation - Determining longest line segment within polygon that passes through its centroid?


A PhD student approached me recently asking how one would determine the longest straight line that passes through the centroid of a polygon, the output being a polyline rather than just a table of numbers. The polyline would be within the polygon starting at the edge at one end, passing through the centroid, and then end at the opposite edge.


Does anyone know how to calculate this?


I'm surprised (but I guess I'm showing my ignorance) that this is not some interface in ArcObjects.


The polygon represents the crater edge of a volcano with no islands so the polygon can have an irregular shape.



Answer



A radial sweep algorithm will do fine, Duncan. Be aware that the centroid can lie outside the polygon, whence there won't exist any solution in such cases. Notice, too, that this construction is a strange one: whereas the centroid is a global property of the polygon, the line you are constructing is a local property of the polygon in the vicinity of this centroid. The combination doesn't make sense for most geometric or physical analyses where the polygon can possibly be non-convex or non star-shaped with respect to its centroid. (This explains why you won't find it in ArcObjects nor, likely, anywhere else.) You might inquire more deeply of the student to find out what s/he is attempting to do with this construction to make sure it meets its intended purpose.


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...