# Determine roundness of polygon in QGIS

Suppose a polygon layer in QGIS with differently shaped polygons (no multi-geometries, let's keep it simple). Is there a way to calculate some kind of roundness characteristic of the individual polygons. I imagine a value of 1 would be a perfect circle and 0.01 would be some kind of lengthily stretched out polygon (and the edge case, 0 would be a line). In the Field Calculator, it would probably look something like this:

`````` exterior_ring( geom ) / \$area
``````

but I don't know what to put in `geom` to get a useful number. Of course, if there is a more elegant solution to get some kind of measure of shape, I am open for suggestions.

I need this to get rid of really thin polygons after a clip operation. I put that in bold, because I just noticed that's a really useful information!

I'd need a solution I can use in Field Calculator or with some plugin.

• Something like gis.stackexchange.com/q/85812/2856 perhaps? Commented Sep 14, 2020 at 20:05
• as soon as will have a layer with only valid geometries, we'll find out. Still cleaning, as `fix geometries` couldn't get the job done. Trying to eliminate duplicate nodes, now. Commented Sep 14, 2020 at 22:46
• @user2856 yes. and with that, I vote to close this question. Although the provided answer is a nice one, it doesn't replace or significantly add value to the answers to the related question. Commented Sep 14, 2020 at 23:00
• The other post is about calculating roundness which is a math problem. This one is about calculating roundness in QGIS which is a QGIS problem. Both are similar but not duplicate. Commented Sep 15, 2020 at 13:23
• Yes, it is distinct enough. If you ask this question for ArcGIS, it also will be a different question. Commented Sep 15, 2020 at 13:49

Roundness is simply the ratio of the area of the circle with the same length as the polygon to the polygon area (`area(Circle)/area(Polygon)`) or vice versa (it depends).

$circle\textunderscore&space;perimeter&space;=&space;2\pi&space;r&space;\Rightarrow&space;r&space;=&space;circle\textunderscore&space;perimeter&space;/&space;2\pi$

$circle\textunderscore&space;perimeter&space;=&space;polygon\textunderscore&space;perimeter&space;\Rightarrow&space;{\color{DarkOrange}&space;r&space;=&space;polygon\textunderscore&space;perimeter/2\pi}$

$circle\textunderscore&space;area&space;=&space;\pi&space;r^2&space;\Rightarrow&space;circle\textunderscore&space;area&space;=&space;\pi&space;{\color{DarkOrange}&space;(polygon\textunderscore&space;perimeter&space;/&space;2\pi)}^2$

$\Rightarrow&space;circle\textunderscore&space;area&space;=&space;polygon\textunderscore&space;perimeter^2&space;/&space;4\pi$

Open Field Calculator, select field type, run the following expression:

``````(\$perimeter * \$perimeter / (4*pi()) ) / \$area
``````

For a circle-shaped polygon, it returns ~1; for a square, ~1,27; for a line-shaped polygon, ~0.

This article includes other shape characteristics: Performance of shape indices and classification schemes for characterising perceptual shape complexity of building footprints in GIS

• For one, nice paper, even the main subject is polygon complexity and not roundness per se. Secondly, I always get the same error, something like "cannot convert 'nan' to float" (I use a German speaking version), no matter what expression I try. I tried the following and keep getting the same error `(\$perimeter * \$perimeter / (4*pi()) ) / \$area` `\$area * 4 * pi() / ( \$perimeter ^ 2)` `\$area * 4 * to_real( pi()) / ( \$perimeter ^ 2)` `\$area * 4 * round(pi(),5) / ( \$perimeter ^ 2)`. Commented Sep 14, 2020 at 22:02
• I don't get any error. There could be invalid geometries in your data. Try to use `Check Validity` and `Fix Geometry` tools. Also Check `\$perimeter` and `\$area` of polygons by adding new fields. Commented Sep 14, 2020 at 22:15
• Dixing geometries is a thought that crossed my mind after my application crashed. Restarting now and will do just that. Already added the two fields to delete faulty polygons of very small area and very small perimeter. Calculating Polby-Popper will give me the last crappy polygons, I hope. Commented Sep 14, 2020 at 22:19