3

I'm looking to create five fields of grouped means within 33 shapefiles. I'm using the Graphical Modeler to save me using the Field Calculator 5 x 33 times.

The new fields are the means of the traffic volumes ("AADT") of five modes, grouped by road types ("DESC_TERM") in the shapefiles. These functions work when calculating 'manually':

mean( "AADTallc_1" ,  "DESC_TERM" , "AADTallc_1" != 0.0)
mean( "AADTalllgv" ,  "DESC_TERM" , "AADTalllgv" != 0.0)
mean( "AADTTaxi" ,  "DESC_TERM" , "AADTTaxi" != 0.0)
mean( "AADTMotorc" ,  "DESC_TERM" , "AADTMotorc" != 0.0)
mean( "AADTLtBus" ,  "DESC_TERM" , "AADTLtBus" != 0.0)

I've created this flow on Graphical Modeler:

Model flow

Where for LGVs (where the model fails);

LGVs input

With the failure message "An error occurred while evaluating the calculation string: Cannot use aggregate function in this context":

Failure message

What could be going wrong?

I tried changing the parameters, but nothing seems to work.

  • Did you find any documentation that says that this should work? I'm not sure it's possible to calculate aggregates like this. – underdark Jan 20 '18 at 19:57
  • Not in particular, I was following this video for the basic structure: youtube.com/watch?v=XyPW8mzssZE It works for the first procedure (road_car) but not the second – MoMiJi Jan 21 '18 at 14:10
  • What does road_car do? Please include a screenshot – underdark Jan 21 '18 at 16:34
  • road_car produces the same output as the LGVs step but for cars, using mean( "AADTallc_1" , "DESC_TERM" , "AADTallc_1" != 0.0) under Formula. – MoMiJi Jan 22 '18 at 16:42
  • Same problem for me with 2.18.16. When i use refactor fields with 'aggregate' function from processing toolbox , it works. But not in model... Formula is concatenate( "vote" , "id_ws" , "user" NOT LIKE 'zp%' AND "user" NOT LIKE 'zp%') – jlSta Jan 26 '18 at 14:41
4

The issue looks solved.

You should update since 2.18.17 is released or try to install nightly from osgeo4w with the advanced install.

https://issues.qgis.org/issues/17300

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.