# Finding the major axis of a polygon (the outline of a sinkhole or doline)

I am using QGIS to do a morphometric analysis of dolines (sinkholes). The dolines have different shapes from circular to elliptical and I need to calculate the major axis of the polygon that represents them. I already use the minimum delimiter box algorithm, which gives me information about the length and width. Now I need to represent the maximum axis inside the polygon and I can not find any method.

Images of minimum bounding box examples taken from Kobal 2015 and Bondensan et al, respectively.

• @AndreSilva well, taking e.g. the images legend by its word it seems a line between the 'farthest points' are what OP needs. being used to PostGIS `ST_LongestLine`, I find the lack of singular methods indeed disturbing; neither QGIS processing nor SpatiaLite provides anything similar...or am I, too, not finding it? – geozelot Feb 7 '19 at 9:45

Here's a method to create a line between the two furthest points on a polygon.

1. Use the `Extract Vertices` tool to convert the vertices of a single sinkhole into points.

2. Use the `Distance Matrix` tool to create a Summary Distance matrix.

1. Open the attribute table, sort by the Max column, and select the two points with the highest Max value. These are the two points furthest from each other on the sinkhole boundary.

1. Use the `points to path` tool to create a line between the points.

Tips for batch processing:

• If you have many sinkholes to repeat this process for each point, try using the Graphical modeler to automate the process.
• If the Distance Matrix tool takes a long time to run, you can speed it up by using fewer vertices.
• Method 1: Before extracting the vertices, use the `Simplify` tool to reduce the total number of vertices in the polygon. You can run this tool on the entire layer at once, rather than doing each sinkhole one at a time. This is the faster of the two methods, but it will give less accurate results than method 2.
• Method 2: After extracting the vertices, manually select the vertices at either end of the sinkhole. Run the `Distance Matrix` on Selected features only.
• Instead of creating a line every time you create a pair of points, leave it until last and create all the lines at once. Once you have all the point pairs, combine them into a single layer. Do a spatial join between the points and the sinkholes to add the unique sinkhole ID to the point attributes. Use the `Points to Path` tool to join the points, using the sinkhole ID for the "Group by" parameter.
• If you have a peanut-shaped polygon (like in the second image) this method might create an axis that crosses the outer boundary of the polygon. You'll have to figure out how you want to handle that situation if it occurs. – csk Feb 7 '19 at 20:41