This one works. I spent an hour trying to figure out how to manage the quotes properly in my expression!# --------------------------------------------------------------------------- # adjacent.py # Created on: 2012-07-12 15:14:17.00000 # (generated by ArcGIS/ModelBuilder) # Usage: adjacent <countyName> # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Set Geoprocessing environments arcpy.env.scratchWorkspace = "C:\\ESRItest\\model\\process.gdb" arcpy.env.workspace = "C:\\ESRItest\\model\\process.gdb" #overwrite pre-existing files arcpy.env.overwriteOutput = True # Script arguments #countyName = arcpy.GetParameterAsText(0) countyName = raw_input('What County do you want to select?') # Local variables: county = "county" county_Layer = "county_Layer" countyList = [] txt_list = "" #Output_Feature_Class = "C:\\ESRItest\\model\\process.gdb\\county_CopyFeaturesOutput" # Process: Make Feature Layer county_Layer = arcpy.MakeFeatureLayer_management("C:\ESRItest\model\process.gdb\county", county_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;Shape Shape VISIBLE NONE;NAME NAME VISIBLE NONE;CNTY_FIPS CNTY_FIPS VISIBLE NONE;FIPS FIPS VISIBLE NONE;POP2005 POP2005 VISIBLE NONE;POP05_SQMI POP05_SQMI VISIBLE NONE;SQMI SQMI VISIBLE NONE;NAME2 NAME2 VISIBLE NONE;Shape_Length Shape_Length VISIBLE NONE;Shape_Area Shape_Area VISIBLE NONE") #Process: Select Layer By Attributes #print countyName whereClause=" \"NAME\" = " + "'"+countyName+"'" #print whereClause countySelection = arcpy.SelectLayerByAttribute_management(county_Layer, "NEW_SELECTION", whereClause) # Process: Select Layer By Location results = arcpy.SelectLayerByLocation_management(countySelection, "BOUNDARY_TOUCHES", "", "", "NEW_SELECTION") # Process: Copy Features #arcpy.CopyFeatures_management(county_Layer, Output_Feature_Class, "", "0", "0", "0") ## Step through the selection to get the values from the name field rows = arcpy.SearchCursor(results,"","","NAME","NAME") for row in rows: neighborVal = row.getValue("NAME") if neighborVal != countyName: countyList.append(neighborVal) txt_list = ','.join(countyList) print txt_list
I still need to figure out how in the world to manage this as a call from Java. At least I can give input and receive output from within the Python window.Thanks so much Chris for your assistance!!!!!