import arcpy from arcpy import env env.workspace = "D:\\Lee\\IrrigationProject" In = "boombuffer.shp" Out = "D:\\Lee\\IrrigationProject\\IrrigationModel\\BoomBuffers\\Boom" Boom = 1 arcpy.Select_analysis(In, Out + str(Boom) + ".shp" , '"BoomNumber" = 'Boom'')
Solved! Go to Solution.
import arcpy from arcpy import env env.workspace = "D:\\Lee\\IrrigationProject" In = "boombuffer.shp" Out = "D:\\Lee\\IrrigationProject\\IrrigationModel\\BoomBuffers\\Boom" boom_list = [] boom = None field_name = "BoomNumber" delim_field_name = arcpy.AddFieldDelimiters(env.workspace,field_name) # Creates and runs cursor to add all unique values to a list s_curs = arcpy.SearchCursor(In) for s_row in s_curs: add_val = s_row.getValue(field_name) if add_val not in boom_list: boom_list.append(add_val) # Loops through list of unique boom values and export each one to a new shapefile for boom in boom_list: arcpy.Select_analysis(In, Out + str(boom) + ".shp", "{0} = {1}".format(delim_field_name,boom)
variable = "Boom" field_name = "BoomNumber" delim_field_name = arcpy.AddFieldDelimiters(env.workspace,field_name) arcpy.Select_analysis(In, Out + str(Boom) + ".shp", "{0} = '{1}'".format(delim_field_name,variable)
import arcpy from arcpy import env env.workspace = "D:\\Lee\\IrrigationProject" In = "boombuffer.shp" Out = "D:\\Lee\\IrrigationProject\\IrrigationModel\\BoomBuffers\\Boom" boom_list = [] boom = None field_name = "BoomNumber" delim_field_name = arcpy.AddFieldDelimiters(env.workspace,field_name) # Creates and runs cursor to add all unique values to a list s_curs = arcpy.SearchCursor(In) for s_row in s_curs: add_val = s_row.getValue(field_name) if add_val not in boom_list: boom_list.append(add_val) # Loops through list of unique boom values and export each one to a new shapefile for boom in boom_list: arcpy.Select_analysis(In, Out + str(boom) + ".shp", "{0} = {1}".format(delim_field_name,boom)