I have a model (ModelBuilder) and within I added a python script to calculate a field. My problem now is, that I don't know how to make the output appear in my model as it is the same as the input (only with the field calculated).
I imagine there is a very simple way, but I am new to ModelBuilder and python and just can't think of it?
Alternatively, I could also try using the field calculator, but I would prefer it this way.
And here is my script:
import arcpy
from arcpy import env
env.workspace = arcpy.GetParametersAsText(0) # the workspace
inLayer = arcpy.GetParameterAsText(1) # The shapefile
inField = arcpy.GetParameterAsText(2) # The column in attr table with Area
outField = arcpy.GetParameterAsText(3) # The column in attr table which should be calculated
# Create a list from area field and find min & max value
listing = []
rows = arcpy.SearchCursor(inLayer)
for row in rows:
listing.append(row.getValue(inField))
del rows
listing.sort()
min = listing[0]
max = listing[-1]
# Calculate the normalized value
rows2 = arcpy.UpdateCursor(inLayer)
for row2 in rows2:
row2.setValue(outField, (max - row2.getValue(inField))/(max - min))
rows2.updateRow(row2)
del rows2