I'm creating a tool that when you type in the city name it will select the city, zoom in and label it. I have the zoom and label working but can't figure out the SQL Query needed to select the city I type in the tool in ArcMap. My code in below.
I'm still new at this
import arcpy as ARCPY
def citySelect():
mxd = ARCPY.mapping.MapDocument("CURRENT")
df = ARCPY.mapping.ListDataFrames(mxd)[0]
city = ARCPY.GetParameter(0)
cities = ("N:/Lab13/Lab13/cities.lyr")
ARCPY.SelectLayerByAttribute_management("cities", "NEW_SELECTION",''' "CITY_NAME" = ' city ' ''')
print city[0]
layers = arcpy.mapping.ListLayers(mxd, "", df)
citiesLayer = layers[0]
df.zoomToSelectedFeatures()
citiesLayer.showLabels =True
ARCPY.RefreshActiveView()
citySelect()
No comments:
Post a Comment