Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Arcpy changing current working directory

$
0
0
I can't seem to understand the following behaviour:

Code:

mxd = ur'G:\MapImageCreator\ImageTaker.mxd'

print os.getcwd()                          # C:\Documents and Settings\dabkowsk\Desktop (where I run the script from)
mxd = arcpy.mapping.MapDocument(mxd)
print os.getcwd()                          # G:\MapImageCreator

Why does creating a MapDocument object change my working directory? This way I can't use any relative path in my entire script. For example, if I describe an output file as just 'abcdefg.txt', it gets created in the mxd's directory, not in the one I run the script from.

Viewing all articles
Browse latest Browse all 2485

Trending Articles