I'm trying to work out how to calculate the length of a line to only 2 decimal places in QGIS. When I use the field calculator to create a new field, it doesn't matter what changes I make to the field type, field width or precision, I continually get the length to 13 decimal place.

3 Answers 3


In the latest dev QGIS version there is a new round function which you can use to control the number of decimal places:


Result: 1.10228762876525 -> 1.102

  • I guessed that there would be a simple expression, thanks Nathan
    – geosmiles
    Commented Jan 14, 2013 at 12:05
  • when 1.9 rolls out?
    – nickves
    Commented Jan 14, 2013 at 14:36
  • 1
    1.9 is not being released. 2.0 is the next release hopefully in the next few months.
    – Nathan W
    Commented Jan 14, 2013 at 22:33
  • where do i insert this function in the field calculator (in qgis 2.18)?
    – newGIS
    Commented Mar 1, 2020 at 13:10

You need to save the file, before the changes to precision are fully displayed.

  • 2
    In QGIS Master, you also have to leave edit mode and/or close and reopen the attribute table.
    – AndreJ
    Commented Jan 14, 2013 at 10:46
  • I work with QGIS 2.8.6 and this function doesn't work for me... Commented Oct 3, 2016 at 11:08

Best solution:

Load plugin : "Processing", Spatial data processing framework for QGIS

Select commandos in the menu bar "processing"

Type "field" in combobox

Select: "Processing algorithm: Refactor fields"

Set decimal positions in the fields

(If there are any items in the expression column are signed red just add "......" at begin and end (shapes don't like long column names with a space (so for example: column x coord has to be "x-coord")

Save to new file or temporally (so you can overwrite your excisting shape).


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.