ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS 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
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

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 use 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

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal