Using Python to calculate attribute values with 'fieldpyculator'

The fieldpyculator plugin provides Python power to your calculations. It's available in the QGIS plugin repository and thus installable with 'Fetch Plugins'; source available on github. According to their webpage, FieldPyculator was developed by GIS-Lab.

They have a Russian-language introduction to the plugin on their webpage, with an excellent Google translation.


Use the toolbar button or the Plugins|FieldPyculator menu to open the dialog.

  • Enter your Python code in the "Field expression" text box. Values are assigned by the "value =" statement - this must exist in some form in the final code.
  • If you need other libraries, or to set up variables or any other code that runs once before the field expression, tick the 'Global expression' button and enter the code in that text box.
    • For example, to use the datetime functions, you would enter 'import datetime' as the Global Expression and could then use a command like 'value =' as the Field Expression.
    • You could also set a variable in the Global Expression (such as 'f = 123.45') and use that in calculations.

See other notes on using fieldpyculator on my blog - using this Redmine system is incredibly frustrating and efforts will continue there. HF

by_default_2012-09-30_at_07.47.36.png (55.4 KB) Howard Frederick, 2012-09-29 10:55 PM

fp_open.png (41 KB) Howard Frederick, 2012-09-29 11:07 PM