gshdet

Merging with Python

Discussion created by gshdet on Jun 22, 2012
Latest reply on Nov 27, 2012 by negeise
Hello,

I hope somebody can please help me with a script i am developing below. It buffers an input and then select the features within the buffer but then doesnt do the merge. I assume it is to do with the List i am using as the merge input. When i run this through the python window in ArcMap it seems to work.

Any help will be greatly appreciated as i am quite stuck at the moment and have tried everything i can think of.

Thank you

James

import arcpy, os, string, arcgisscripting

#Read input parameters from script tool
LayersList = string.split(arcpy.GetParameterAsText(0),";")
Site_Boundary = arcpy.GetParameterAsText(1)
BufferDistance = arcpy.GetParameterAsText(2)
OutputFolderLocation = arcpy.GetParameterAsText(3)


# Process: Buffer
arcpy.Buffer_analysis(Site_Boundary, OutputFolderLocation + "\\" + BufferDistance + "_Buffer.shp", BufferDistance, "FULL", "ROUND", "NONE", "")


# Process: Loop Layers
for Layer in LayersList: 

# Get filename of layer
LayerName = os.path.basename(Layer).strip("'") + "_FL"

# Process: Make Feature Layer (In, Out)
arcpy.MakeFeatureLayer_management(Layer.strip("'"), LayerName)

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(LayerName, "INTERSECT", OutputFolderLocation + "\\" + BufferDistance + "_Buffer.shp", "0 Meters", "NEW_SELECTION")

arcpy.CopyFeatures_management(LayerName, OutputFolderLocation + "\\" + LayerName)

#Create List and Add Layers to the List
L = list ()
L.append(LayerName) 

# Process: Merge Selected Features
arcpy.Merge_management(L, OutputFolderLocation + "\\All_Sites.shp")

Outcomes