1

I've got a shapefile with about 30 fields that I'll need to update from time to time by importing a CSV with new data, joining it to the shapefile, and using the field calculator to carry the new values into the old fields one at a time:

enter image description here

However, this is a tedious process, and it seems like something ripe for automation with pyQGIS. The target field names and corresponding join field names will not change over time.

I have a sense of what this would look like in SQL, but the python version escapes me, and this documentation is thin on field calculation.

Is it even possible to automate a batch of field calculations like this?

2
  • So it's just the update that you want to script?
    – Nathan W
    Commented Apr 25, 2014 at 5:47
  • Exactly; string together multiple updates. And the schema will be the same every time, just the values will change. Commented Apr 25, 2014 at 14:22

1 Answer 1

0

Since the ultimate destination of this file was PostGIS, I moved the process to a SQL script. It'd be nice to know how to do this with pyqgis, but no longer necessary for my purpose.

2
  • You could try using a model in the Processing Toolbox Commented May 15, 2014 at 19:35
  • Good call, but I was hoping to see code :) Commented May 20, 2014 at 18:56

Your Answer

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

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