How to get a value from a row in .shp and update new column in corresponding row

المشرف العام

Administrator
طاقم الإدارة
I am outputting a shapefile from an intersection, and adding to it the columns “intersec_area” and “percent_area”. I have intersec_area working but I want to calculate percent_area by taking intersec_area, multiplying it by 100 and dividing by the column in the table named “AREA” (e.g. percent_area=(intersec_area/AREA) * 100). Here is what I have so farout_path = '\\storage1\gis\output.shp' arcpy.Intersect_analysis([sys.argv[1], sys.argv[2]], out_path, "ALL")

arcpy.AddField_management(out_path, "intersec_area", "DOUBLE")arcpy.AddField_management(out_path, "percent_area", "DOUBLE")arcpy.CalculateField_management(out_path, "intersec_area","!SHAPE.AREA@SQUAREMETERS!", "PYTHON")stub = """def getArea(): return 2"""arcpy.CalculateField_management(out_path, "percent_area", "getArea()", "PYTHON", stub)What goes in the function “stub” to read each AREA on each line and update the corresponding percent_area record?



أكثر...
 
أعلى