I'm trying to write a script to add raster layer to my mxd from the server but i am not sure if the path to the server is correct ?
import arcpy, os arcpy.env.workspace=(r"S:\Las Cruces SSO\GIS_Master_Data\NAIP_2009\Dona Ana") mxd = arcpy.mapping.MapDocument(r"E:\ArcMap\Retrieve_NAIP.mxd") df = arcpy.mapping.ListDataFrames(mxd,"Layers") addlayer = arcpy.mapping.Layer('S:/Las Cruces SSO/GIS_Master_Data/NAIP_2009/Dona Ana') arcpy.mapping.AddLayer(df, addlayer,"AUTO_ARRANGE") mxd.saveACopy("E:\ArcMap\Retrieve_NAIP.mxd") del mxd, addlayer
look at the number 05 here is that the raster reside is on the server . The mxd file is on my hard drive.
Thanks,
Robert
Robert,
i would suggest you try and use a UNC path if possible, that way the script can be shared with other people and the path should still work without the other person having the same shared drive letters, eg:
addLayer = arcpy.mapping.Layer(r"\\<servername>\<Shared Directory>\Las Cruses SSO\.......\layername.lyr")
Note your path must actually be to an existing .lyr file
Regards
Anthony
I took care of it and now it is working that I am enable to connect the server without any problems.