# How to draw a longest and shortest straight lines through centroid in polygon?

I have a task I thought some of you might have idea how to solve it.

I have shape and a centroid in it. I need to find longest and the shortest straigt line from the borders of the polygon.

• Good question. This tutorial is far to solve your question but could be useful for you! qgistutorials.com/en/docs/nearest_neighbor_analysis.html Jun 1, 2016 at 14:13
• @WKT The longest distance has to be from the centroid to a polygon vertex so can be done with an exhaustive search over vertices, but the shortest distance can only be done with a search over distances from centroid to polygon line-segments since a segment might pass close to the centroid with its end vertices far away... Jun 1, 2016 at 14:47
• This can be done in R, which can read in a shapefile. Jun 1, 2016 at 17:16
• Is there a requirement that the line(s) go through the centroid? Does it need to work for both convex and concave polygons? For polygons with the centroid outside the polygon? Jan 24, 2017 at 18:57