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)

closed as unclear what you're asking by PolyGeo Sep 16 '17 at 20:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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

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


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