What is the correct path for the server ?

3799
2
02-17-2015 01:32 PM
PROBERT68
Frequent Contributor

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

0 Kudos
2 Replies
AnthonyGiles
Frequent Contributor

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

0 Kudos
PROBERT68
Frequent Contributor

I took care of it and now it is working that I am enable to connect the server without any problems.

0 Kudos