3

So I am using QGIS 2.18.15

Strange thing:

If I go via the attribute table into the field calculator and use following formula it works just fine:

if( "DB_arit" IS NULL, 0, "DB_arit" )

Explanation: It searches for NULL values in the column "DB_arit" and replaces them with "0", all other values stay the same.

Now if I use the modelbuilder I get the following error:

Algorithmus Test Field calculator NULL to 0 in DB_arit startet... Bereite Algorithmus vor: QGISFIELDCALCULATOR_1 Verarbeite Field calculator Field calculator NULL to 0 in DB_arit [1/1] Parameters: INPUT_LAYER =replacedbyme.shp, FIELD_NAME =DB_arit, FIELD_TYPE =0, FIELD_LENGTH =10, FIELD_PRECISION =2, NEW_FIELD =False, FORMULA =if("DB_arit" IS NULL, 0, "DB_arit" ) Fehlgeschlagen

Fehler in Algorithmusausführung Field calculator Field calculator NULL to 0 in DB_arit QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type 'NoneType' See log for more details

(Don't wonder aboout "Input_Layer=", I edited it just for this post)

Can anyone explain or help?

2
  • 1
    Your formula works for me just fine, assuming you used "Field Calculator" in the Graphical Modeler. Perhaps try changing the field type to integer/float and see if it works? Also make sure you have no features selected, and test the model on other input files.
    – 15Step
    Jan 11, 2018 at 14:18
  • Thanks for your input.Because it worked in your case I knew the problem was my shapefile and not my code, see my answer.
    – M.S.
    Jan 11, 2018 at 15:18

1 Answer 1

1

Ok, I have identified the cause for this.

Problem were some NULL geometries in the shapefile, that caused to crash the process in the Graphical Modeler...

I am still not sure why it doesn't crash when doing this formula in the attribute table directly vs in the Graphical Modeler.

But the solution was to insert an algorithm from the toolbox which deletes NULL geometries into the Graphical Modeler first and then run my code from above!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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