Edit shapefile using modelbuilder

2097
1
09-09-2013 04:03 AM
PV1
by
New Contributor
I have got the folloving problem:
I need to change some of the values of one attribute in my point shapefile. I want to do it in modelbuilder, but I dont know how. I have found a script which can do it in python. The script is as following:

import arcpy
... 
... features = arcpy.UpdateCursor(r"C:\Users\peter.valent\Documents\ArcGIS\Data\Vah po LM\test_points.shp")
... for feature in features:
...         feature.precipitation = value
...         features.updateRow(feature)
... del feature,features


This is what I put to modelbuilder:
Expression:
myfcn(r"%file_name%","%value%")

Code Block:
import arcpy

def myfcn(path,value):
features = arcpy.UpdateCursor(path)
for feature in features:
        feature.precipitation = value
        features.updateRow(feature)
del feature,features
0 Kudos
1 Reply
ScottMoyer
Occasional Contributor
1. Create new model in a Toolbox
To update values within fields using ModelBuilder, using tools in 10.0 'Data Management Tools':
2. 'Make Feature Layer' in 'Layers and Table Views'
3. 'Select Layer By Attribute' in 'Layers and Table Views'
4. 'Calculate Field' in 'Fields'

That should do it.

Scott
0 Kudos