1

I am trying to follow some tutorials using Advanced Python field calculator, but when I enter the formula value = $geom.area() / < area> I get syntax error as in picture, while if I substitute the field name in pointy brackets with a number (eg. 1000) it works fine.

I have already checked the link http://hub.qgis.org/issues/9867 but still cannot find any documentation on the tool syntax

enter image description here

  • 1
    I would try using double quotes or no escape characters at all. – Michal Zimmermann Jul 21 '15 at 16:01
  • 1
    I afraid it still doesn't work for me: with quotes (both single and double) I get error unsupported operand type(s) for /: 'float' and 'str' , and with no escape character I get error name 'area' is not defined . In general, it would be good to know where to find syntax documentation if any available – dorakiara Jul 22 '15 at 7:36
  • A number of articles point to a Russian website (which can be translated using Google) with a tutorial on how to use the FieldPyculator plugin, the knowledge can be transferred to the Advanced Python Field Calculator. Other than that, there's not much else I could find. – Joseph Jul 22 '15 at 10:38
  • Thanks, I used the FieldPyculator to test my syntax. I am afraid it was a very sill error: field name should be capitalized as in the original file, so correct syntax was simply value = $geom.area() / <AREA>. Also the link is a good source of information. – dorakiara Jul 22 '15 at 13:57

Your Answer

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

Browse other questions tagged or ask your own question.