[GIS] Batch Update Fields in Field Calculator or Model

clipfield-calculatorqgis

I have a dataset of block-level census data that I clipped to an Illinois State Senate district. To update the data (e.g. for population) I'm applying an area multiplier, i.e taking the area of each attribute after and dividing it by the area before and applying the percentage to each field. Since I wasn't aware of how to do a geoprocessing clip that would also clip data I'm left editing the table manually

My question is: how do I batch multiply columns against one column? I have 100 columns of data I need to multiply against a percentage contained in an aptly named proportion column. Can this be done through a model in ArcGis, or through a Python script in the Field Calculator? I have both QGIS and a demo license of ArcGis available.

Best Answer

You should be able to write this in a python scripting using an update cursor fairly easily.

import arcpy
tablename = "c:\temp\*NAMEOFYOURTABLE*"
fieldvalues = ['fieldname1','fieldname2','fieldname3'......'fieldnameX']

cur = arcpy.UpdateCursor(tablename)
for row in cur:
    sourcevalue = row.getValue('*name of field where source value coming from*')
    for f in fieldvalues:
        row.setValue(f, sourcevalue)
    cur.updateRow(row)
Related Question