Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

I would have posted an image to explain what I am asking (I hope it is clear) but as a newbie to this site I was not allowed to upload images!

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

share|improve this question
add comment

1 Answer 1

up vote 9 down vote accepted

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.

share|improve this answer
1  
Wow thanks for the mega fast response! You've both given me some keywords to look up. "Radial sweep" sounds complex... –  Hornbydd Oct 1 '10 at 19:15
    
Note too that there are polygons where there is no "the longest straight line"; instead, there may be many possible lines. [[Also, I bet $1 that the student in question is designing a transect survey(s).]] –  Dan S. Oct 1 '10 at 19:20
    
@Hornbydd: There's complex, and there's complex. Implementing a radial sweep is not too hard as far as computational geometry goes, but diving into writing computational geometry code for the first time can be intimidating. I'd be happy to type out some pseudocode for you if you want a starting point. –  Dan S. Oct 1 '10 at 19:27
    
Dan, I apreciate your offer but I'm not the students supervisor, just some random guy she had contacted. Although as a GIS developer I would be interesting to see some pseudocode to get the basic idea of a radial sweep, but please don't spend any time on it as you have already given me some pointers which is much appreciated. –  Hornbydd Oct 1 '10 at 19:41
2  
On a lighter note, I posted my question on this site, saw whuber's response went off and made a coffee, came back, typed into google "radial sweep polygon centroid" and immediately came back to this page! How on Earth did Google find this page so quickly and integrate it into their search, the mind boggles. –  Hornbydd Oct 1 '10 at 19:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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