How can I find polygon's length and width in QGIS (regular polygon and irregular polygon)?

I have area and perimeter but not length and width.

enter image description here


2 Answers 2


You could use the "Oriented minimum bounding boxes" first then run the "Polygons to lines" tool.

The output of Polygons to lines will have area, perimeter, angle, width and height of the minimum bounding box already calculated.

These results will be exact for square and rectangular shape and get worse the more your input polygon is irregular....

enter image description here


Here are the custom expressions I used with Field Calculator for 4 sided polygons , to create "Length" and "Width" attributes that can be used to quickly identify the rectangle size, or to create a dynamic label. Notice I use array_max and array_min to find Length or Width respectively, and a properly closed 4 sided polygon will have 5 vertices.

Length: If( num_points( $geometry )=5, array_max( array( distance( point_n( $geometry ,1),point_n( $geometry ,2)), distance( point_n( $geometry ,2),point_n( $geometry ,3)))),0)

Width: If( num_points( $geometry )=5, array_min( array( distance( point_n( $geometry ,1),point_n( $geometry ,2)), distance( point_n( $geometry ,2),point_n( $geometry ,3)))),0)

Field Calculator example

  • Thanks can you specify in the answer how to make Qgis calculate those fields for all polygons on layer? Thanks
    – Louis
    Commented Jun 28, 2023 at 7:24
  • To add an attribute for all the polygons in the layer, right-click the polygon layer, select 'Open Attribute Table', then select the 'open field calculator' button or press Ctrl + I.
    – ddgeo
    Commented Jun 29, 2023 at 13:01

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.