About using environment settings
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 can 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 (extent), the coordinate system of the output dataset, and the cell size of a new raster dataset, can all be specified in the geoprocessing environments.
In a program, the geoprocessor object possesses all default environment values. You can get the default value or change it. The environment values remain in effect within the current geoprocessing session. The following table shows the environment methods the geoprocessor has to work with:
Method
|
Description
|
GetEnvironmentValue(envName)
|
Retrieves the value of an environment by name.
|
SetEnvironmentValue(envName, envValue)
|
Updates the value of an environment by name.
|
Resets the environments to their default state.
| |
ListEnvironments("*")
|
Returns the list of environments (properties).
|
SaveSettings(sFileName)
|
Saves the current settings (toolboxes, environments, and so on) to a file on disk in Extensible Markup Language (XML) format.
|
LoadSettings(sFileName)
|
Loads the current settings from the saved file.
|
All environment names are passed as strings. Environment names are not case sensitive; therefore, it does not matter if "workspace" or "Workspace" is used.
The following is a code example to set environment values. By default, the output of Copy Features geoprocessing tool gets the coordinate system of the input. By setting a different value, you override the default coordinate system.
[C#]
[VB.NET]
The following code example shows how to retrieve and reset environment values:
[C#]
[VB.NET]
The ListEnvironments method returns a list of environments. This method has a wildcard option, and returns an
IGpEnumList of strings that can be looped through. The following code example shows how to list environments. The method returns all environments that start with the letter "q" (for example, qualifedFieldNames).
[C#]
[VB.NET]
After setting several environments using the SetEnvironmentValue method, you can save them to an XML file, then use them later by loading the settings with the LoadSettings method as shown in the following code example:
[C#]
[VB.NET]
Environment settings summary table
The following table shows the geoprocessing environments in alphabetical order. The first column in the table is the name of the environment. You must pass this name as a string to the geoprocessor's GetEnvironmentValue and SetEnvironmentValue methods. The second column is the display name as shown on the Environment Settings dialog box.
Each environment display name in the table links to the reference page of that environment, which explains what the environment is for and what values can be set for it.
Environment names are not case-sensitive in .NET.
Environment name
|
Display name
|
autoCommit
| |
cartographicCoordinateSystem
| |
cellSize
| |
coincidentPoints
| |
compression
| |
configKeyword
| |
derivedPrecision
| |
extent
| |
geographicTransformations
| |
maintainSpatialIndex
| |
mask
| |
MDomain
| |
MResolution
| |
MTolerance
| |
newPrecision
| |
outputCoordinateSystem
| |
outputMFlag
| |
outputZFlag
| |
outputZValue
| |
projectCompare
| |
pyramid
| |
qualifiedFieldNames
| |
randomGenerator
| |
rasterStatistics
| |
referenceScale
| |
scratchWorkspace
| |
snapRaster
| |
spatialGrid1, 2, 3
| |
terrainMemoryUsage
| |
tileSize
| |
tinSaveVersion
| |
workspace
| |
XYDomain
| |
XYResolution
| |
XYTolerance
| |
ZDomain
| |
ZResolution
| |
ZTolerance
|