Hi there,
I am trying to select out any polygons from a feature class that are greater than the standard deviation of the entire feature class. I firstly calculate the standard deviation, store that in a variable and then am getting stuck on how I need to incorporate that into my sql query.
It keeps giving me error 000358 when it gets to the SelectByAttribute part and no matter what I change it doesn't appear to make a difference. I am pretty new to this so sorry if it's massively inefficient.
I have posted the code below and any help would be greatly appreciated!
import sys, arcgisscripting
gp=arcgisscripting.create()
gp.OverWriteOutput = True
# Variables
table = "C:\\temp_Statistics"
field="STD_AREA"
# Process
rows=gp.searchcursor(table,"","",field)
row=rows.next()
while row:
queryValue = row.STD_AREA
print queryValue # check that the number is stored in this variable
row=rows.next()
# Make feature layer
in_features = "C:\\tester.shp"
out_layer = "temp_layer"
gp.MakeFeatureLayer_management (in_features, out_layer, "#", "#", "#")
print "made feature layer"
# Select by attribute based upon the value obatained from standard deviation calc.
where_clause = "area" >= queryValue
out_feature_class = "C:\\test_Copy.shp"
gp.SelectLayerByAttribute_management(out_layer, "NEW_SELECTION", where_clause)
print "selected features"
# Copy the selected features to a new layer
gp.CopyFeatures ("temp_layer", out_feature_class, "#", "#", "#")
print "features copied"
Thanks!!