add shapefiles

Discussion created by renesch on Mar 27, 2012
Latest reply on Apr 2, 2012 by mzcoyle
Sometimes the most simple tasks are to most complicated (and thereby frustrating). I just want to add a shapefile in a mxd. I only am able to figure out how to add a layer file:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\gisbestanden\pythontest\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
addLayer = arcpy.mapping.Layer(r"C:\gisbestanden\pythontest\buurten.lyr")
arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE")
del mxd

I see two options, but excuting is another story. First replace addLayer = arcpy.mapping.Layer(r"C:\gisbestanden\pythontest\buurten.lyr") with addLayer = arcpy.mapping.Layer(r"C:\gisbestanden\pythontest\testje.shp") . But that doesn't work. Another one is the make a .lyr from C:\gisbestanden\pythontest\testje.shp, but I can't figure out how? Does anybody have a sollution