# Finding length and width of polygon in QGIS

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.

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....

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)

• Thanks can you specify in the answer how to make Qgis calculate those fields for all polygons on layer? Thanks 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. Commented Jun 29, 2023 at 13:01