6

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.

  • 1
    Something like gis.stackexchange.com/q/85812/2856 perhaps? – user2856 Sep 14 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. – thymaro Sep 14 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. – thymaro Sep 14 at 23:00
  • 1
    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. – Kadir Şahbaz Sep 15 at 13:23
  • 1
    Yes, it is distinct enough. If you ask this question for ArcGIS, it also will be a different question. – Kadir Şahbaz Sep 15 at 13:49
5

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

circle_perimeter = 2πr
-> r = circle_perimeter/2π
-> circle_perimeter = polygon_perimeter
-> r = polygon_perimeter/2π 

circle_area = πr² 
-> circle_area = π(polygon_perimeter/2π)²
-> circle_area = polygon_perimeter²/4π 

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

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

enter image description here

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

| improve this answer | |
  • 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). – thymaro Sep 14 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. – Kadir Şahbaz Sep 14 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. – thymaro Sep 14 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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