AnsweredAssumed Answered

Calculate Field Issue/Script Setup Question

Question asked by jfarmer@cityofstafford on Aug 28, 2013
Latest reply on Aug 28, 2013 by jfarmer@cityofstafford
I am attempting to add a new field to a feature class and then populate it based on a selection by attribute and then location. I originally setup this script to use CopyFeatures and it worked just fine. Instead, I would like to add the results to the new "Zoning" field I just created but do not know how to setup the expression in CalculateField.

# Import Arcpy import arcpy  # Set the workspace arcpy.env.workspace = "J:\\GIS\\Parcel_Data\\Python_Data\\For_Python_Script.gdb"  # Define Variables fieldName1 = "Zoning" fieldLength = "100" Zoning_Designations = "Zoning_Designations" CAMASUMMARY = "CAMASUMMARY"  # Define the feature class used below for adding the zoning field fc = "J:\\GIS\\Parcel_Data\\Python_Data\\For_Python_Script.gdb\\CAMASUMMARY"  # Add the "Zoning" field to the parcel data arcpy.AddField_management (fc, fieldName1, "TEXT", "", "", fieldLength)  # Select all parcels from CAMASUMMARY that match the zoning designations they encompass flayer1 = arcpy.MakeFeatureLayer_management (Zoning_Designations, "Zoning_Layer") flayer2 = arcpy.MakeFeatureLayer_management (CAMASUMMARY, "Parcel_Layer") qry = '"name" = \'ARTS AND EDUCATION\''  arcpy.SelectLayerByAttribute_management (flayer1, "NEW_SELECTION", qry) arcpy.SelectLayerByLocation_management (flayer2, "WITHIN", flayer1) arcpy.CalculateField_management(CAMASUMMARY, fieldName1, ???????


Also, there will be 8 other queries exactly like this one (we have 9 zoning classifications) so can I just run one after the other? I think I need to clear the selection and delete the layers each time correct?

-Jonathan

Outcomes