I wrote the following code for GIS analysis, in which I am trying to find the sum of all pavement area values that meet the condition where Application == "Micro Surface" & CouncilDistrict == 1
.
I have more than 85,000 records in the attribute table with any of six different values for the field named Application
and values ranging from 0 to 10 for CouncilDistrict. I want to find the sum of values for the Pvment_Area
field that meet the condition. I keep getting the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
How do I extract values using NumPy?
import arcpy
import numpy
input = "C:\Temp\Street1.mdb\Scenario_78M"
arr = arcpy.da.FeatureClassToNumPyArray(input, ('Pvment_Area', 'Application', 'CouncilDistrict'))
x=(arr[arr['Application'] == "Micro Surface" AND ['CouncilDistrict'] == 1]]["Pvment_Area"].sum())
print'Pvment_Area is',x