0

I am trying to make a layer from schools that depicts schools at greater than 700 meters. There is an attribute field "ELEV_METER" that has the numeric value for elevation. The query keeps being rejected. I can do this in ArcMAP but need the python script to work. Any ideas?

arcpy.env.overwriteOutput = True


schools = "Schools"
highelevschools = "HighElevSchools"


arcpy.MakeFeatureLayer_management(schools, highelevschools)
arcpy.SelectLayerByAttribute_management(highelevschools, "NEW_SELECTION", "ELEV_METER" >= 700)
  • 1
    is there an error being produced or just an empty output? – NULL.Dude Sep 16 '17 at 18:23
  • What do you mean by "query keeps being rejected"? Does the code you present lead to that and/or an error message or something else? – PolyGeo Sep 16 '17 at 20:21
1

You can specify a SQL query in MakeFeatureLayer so you dont need to use SelectLayerByAttribute (unless you want to, in that case the same SQL query below should work). Try using AddFieldDelimiters and string format:

import arcpy

schools=r'C:\TEST.gdb\schools'

sql="""{0} >=700""".format(arcpy.AddFieldDelimiters(schools, "ELEV_METER"))
arcpy.MakeFeatureLayer_management(in_features=schools, out_layer='highelevschools', where_clause=sql)
| improve this answer | |