Insert Feature Class using arcpy

2358
1
10-27-2011 08:06 AM
CodySchank
New Contributor
I'm using arcpy with ArcGIS and simply want to add a shapefile to the Table of Contents.  The only tools I see that can do this are AddLayer and InsertLayer, which would require me to convert my shapefiles to layers.  Is there a way to add these shapefiles without doing it as a Layer? 

Thanks
0 Kudos
1 Reply
AndrewChapkowski
Esri Regular Contributor
Use makefeaturelayer_management() and use the Layer object to add the layer object to the TOC.

#... other logic
tempLayer = "layer"
# Make a layer from the feature class
arcpy.MakeFeatureLayer_management("C:/data/mexico.gdb/cities",tempLayer)
addLayer = arcpy.Layer(tempLayer)
arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE")
arcpy.RefreshTOC()

0 Kudos