Post

2 followers Follow
0
Avatar

Setting a workspace for python scripting

I am new to using python in PCI, but am wondering is there a command to set the script work space, like you can when using python in Arcmap, so the entire file paths do not need to be copied when setting up variables?

Thanks!

margie massier

Official comment

Avatar

Hi Margie,

In Geomatica there is no concept of a workspace, like in ArcPy. However, there are several ways of doing something similar in python:
1) You can change the current working directory using os.chdir() - https://docs.python.org/2/library/os.html#os-file-dir
2) You can set a variable that represents the working directory, and then use this to create other variables that represent files using os.path.join - https://docs.python.org/2/library/os.path.html#os.path.join
for example:
root_dir = 'path/to/root'
my_file = os.path.join(root_dir, 'mytestfile.pix')

You may wish to take a look at the online python documentation (https://www.python.org/doc/) to learn about the os module, and some of the other python standard library modules, as these are very useful. One of the best features of python is its community. There are many great resources available on the web. For example, here is a good quick tutorial on the python standard library- https://docs.python.org/2/tutorial/stdlib.html.

Hope this helps,

Sarah

PCI Geomatics
Comment actions Permalink

Please sign in to leave a comment.

1 comment