6

I am working through this tutorial:

http://www.qgistutorials.com/en/docs/calculating_line_lengths.html

In the tutorial we import a shapefile map of railroads,clip the data through a selection/calculation to create a new layer. Next we add a new field to this new shapefile table using Field Calculator.

Everything was working until I got to steps 18 and 19 when I need to SUM up the length of all the values in the field.

I am using a later version (2.18.3) So my steps for this process are Vector>Analysis Tools>Basic Statistics for Numeric Fields.

In the Basic Statistics For Numeric Fields dialog box I am able to select the layer, but I am unable to select the field 'length_km2' I think the problem is that the field is the wrong type. The field I need is currently set to 'double' in the table. The type name is 'Real'. I think the type should be 'Real' or 'Integer'. Is there a way to edit the field type? Or is there another way to apply this calculation?

enter image description here enter image description here

1
  • 1
    Another quick method is to open up the Field Calculator for your layer and simply enter the expression: sum("fieldName"). This will show you the sum value in the preview (ofcourse you don't have to create a new field or anything).
    – Joseph
    Commented Mar 22, 2017 at 11:12

1 Answer 1

3

The field type as 'double' is correct and it should show up in the dropdown menu of Field to calculate statistics on. I tried on the same dataset as yours on the same version of QGIS and I did not encounter any problem.

An alternate way to do it would be to use Statistics Panel. You can access it by clicking on 'Show statistical summary' button near the select options and Field Calculator buttons on top -
Show statistical summary

The 'Statistics Panel' should show up on along with the panels on the left -
Statistics Panel

1
  • Thanks for showing me the Statistics Panel option. I was able to get 'basic statistics for numeric fields' to work by adding a .cvst to the same directory. At least I think that is why it is now working!
    – joe d
    Commented Mar 23, 2017 at 14:13

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.