4

I am creating a field for a z-score of a particular attribute. This requires calculating the mean and the standard deviation for the attribute across all features. I've been using the statistics window to get the mean and standard deviation, copying them into a field, and then doing the calculations in a third field, but I feel like that's not very efficient. I can't find a way to calculate the mean using the field calculator and my scripting skills are pretty weak.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Brian
  • 157
  • 1
  • 1
  • 10
  • 1
    check out http://hub.qgis.org/projects/statist/ & http://gis.stackexchange.com/questions/99891/calculating-the-average-mean-of-an-attribute-field-in-a-qgis-model – ed.hank Feb 01 '16 at 22:13
  • The tip on using the modeler is helpful, but I can't figure out how to take the mean value from the basic statistics algorithm and use it elsewhere in the model. Is it possible to simply create a variable with the modeler that I can use in a formula? – Brian Feb 02 '16 at 22:20
  • http://gis.stackexchange.com/questions/143544/how-to-summarize-a-column-in-qgis-field-calculator they say there you cant sum a field in qgis field calculator :/ – ed.hank Feb 02 '16 at 22:53
  • 1
  • 2
    @joseph always good to have updated info! – ed.hank Jul 07 '17 at 19:43

2 Answers2

6

In the Field Calculator, you can use the following Aggregate functions:

  • Mean

    mean( "fieldName" )
    
  • Standard deviation

    stdev( "fieldName" )
    

Tested on QGIS 2.18

Joseph
  • 75,746
  • 7
  • 171
  • 282
-1

Zonal statistics plugin could be used.

https://docs.qgis.org/2.18/en/docs/user_manual/plugins/plugins_zonal_statistics.html