I'm interested in examining the average width of streets, that are irregular polygons, for a project. I'm using QGIS 2.12.0 Lyon, and have lines (power cables) and Polygons (streets) as layers. For further analysis I need to know how wide the streets, which overlap with cables, are on average. I already found a try of a solution for this topic at How can I calculate the average width of a polygon?, but unfortunately I don't get rid of error Messages when I try to apply Peter Krauss's solution in QGIS and I get told it's better to create a new question instead of asking there . It's quite plain to me, that there's no perfect solution for finding the average width for irregular Polygons, but approximatly would be absolutly enough for me. Especially because my knowledge in programming is actually a lot to bad for this.

If the power cables layer overlaps the street layer crosswise, I can use the length of the new layer which is created by intersection.

(street = blue, cable = black, intersect= orange) enter image description here

But if the cable don't overlap crosswise but along the street, I need the average width of the street and not a punctual selection at one point because the width can change. Also there could be curves or crossroads in the street, what makes it even worse.

(street = blue, affected part of the street layer =purple , cable = black, intersect= orange) enter image description here

Futhermore I'm actually searching for an way in which you don't have to do that much manual work like drawing lines, but rather a solution in which you can recall the average width of every street any times.

Perhaps someone can explain all necessary steps so I can use it?

  • Can you post the error message here?
    – raphael
    Nov 23, 2015 at 19:04
  • I have never come in touch with coding in my life until now. So please do not judge me for mostly just trying copying and inserting. I tried to fit the code to my issue but that made it only worse.. I always get: 'SyntaxError: invalid syntax'
    – rr77
    Nov 24, 2015 at 13:41
  • Don't worry, everyone starts somewhere :). The code you linked to is an SQL Query which you can use in PostGIS. You would have to set up PostGIS and import your layer before being able to run the code. Is this what you did?
    – Joseph
    Nov 24, 2015 at 13:56

2 Answers 2


You can start from two known values the area and the perimeter ($area and $perimeter in the filed calculator). As you need an average width, let's imagine we have a rectangle (length, width)

Area = length x width Perimeter = 2 x (length + width)

We have two unknowns and two (non linear) equations, let's substitute length from the first to the second:

length = Area / width Perimeter = 2 x Area / width + 2 x width

Let's multiply the second equation with width and rearrange to get a quadratic equation for width:

2 x width ^ 2 - Perimeter x width + 2 x Area = 0

Solving this you get two roots, the smaller positive value is an average width. It can be used in field calculator to calculate width for each polygon.


This answer isn't specific to QGIS.

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

That is:

  Diameter of a circle with the same perimeter as the polygon
(Area of a circle with the same perimeter as the polygon) / Area

Edit: Writing the formula this way makes the logic of it much clearer:

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

(Diameter of a circle with the same perimeter as the polygon) * Area / (Area of a circle with the same perimeter as the polygon)

See more detail--and an ArcPy implementation--here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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