Show Navigation | Hide Navigation
You are here:
Geoprocessing > Geoprocessing environments

Script environments

Release 9.3
Last modified December 18, 2008
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Geoprocessing environments"


Related Topics

Environments in script tools behave like environments in any other tool; environment values are passed down to the script where they are applied to tools run within the script. You can set environments within a script, thereby overriding any passed-down environments. Environment values set within scripts only apply to the execution of the script; passed-down environment values are not altered. In the following sample script, the current workspace value is overridden in the script.

    import sys, string, os, arcgisscripting
    gp = arcgisscripting.create()

    # Print the passed-down current workspace environment setting
    #
    gp.AddMessage("The passed-down current workspace is: %s" % gp.Workspace)

    # Set a new workspace, overriding the passed-down workspace
    #
    gp.Workspace = "e:\data\script.gdb"
    gp.AddMessage("The new current workspace is: %s" % gp.Workspace) 


View a table of script environment settings

Stand-alone or called scripts


There are two situations where the script does not receive passed-down environment settings. The first is when the script is run outside an ArcGIS application, such as from the operating system command prompt. The second is when a script calls another script; there is no way for the calling script to know that the called script will contain a geoprocessor. In such situations, you can use the geoprocessor LoadSettings method, which can read environment settings from an XML file.

Learn more about saving and loading environment settings in scripts
Learn more about saving and loading geoprocessing environment settings

A script that prints all environment settings


Following is a link to a Python script that you may find useful. It simply prints the values of the current environment settings.
View script code

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.