ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Setting environments in the Python window

  • Keeping track of environments in the Python window

Each tool has a set of parameters it uses to execute an operation. Some of these parameters are common among all tools, such as a tolerance or output location. These parameters may obtain their default values from a geoprocessing environment that all tools utilize during their operation. When a tool is executed, the current environment settings can also be used as global input parameter values. Settings such as an area of interest, the spatial reference of the output dataset, and the cell size of a new raster dataset can all be specified with geoprocessing environments.

In ArcPy, geoprocessing environments are organized as properties under the ArcPy class env. In the example below, several environment values are printed to the display, then set to new values.

>>> print arcpy.env.overwriteOutput
True

>>> print arcpy.env.workspace
None

>>> arcpy.env.overwriteOutput = False
>>> arcpy.env.workspace = "c:/temp"
>>> print arcpy.env.overwriteOutput
False

>>> print arcpy.env.workspace
c:/temp

>>>

Keeping track of environments in the Python window

Since geoprocessing environments can significantly affect tool operation and output, it is important to be able to keep track of environment settings and to reset environments to their default states when necessary.

The ArcPy function ResetEnvironments can be used to restore the default environment values.

>>> arcpy.ResetEnvironments()
>>>

The ArcPy function ListEnvironments can be used to create a list of all geoprocessing environments. This list can be used to access and print all environments and their current values. This example only shows two environments, but all environments and their values are printed using this code.

>>> environments = arcpy.ListEnvironments()
... for environment in environments:
...     envSetting = eval("arcpy.env." + environment)
...     print "%-30s: %s" % (environment, envSetting)
...
newPrecision                  : SINGLE

autoCommit                    : 1000
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal