Using Environment settings |
In this topic
- About using environment settings
- Environment Settings Summary table
About using environment settingsEach tool have a set of parameters it uses to execute an operation. Some of these parameters is common among all tools, such as a tolerance or output location. These parameters can obtain their default values from a geoprocessing environment the all tools utilize during their oper ation. When a tool was 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 RA Ster DataSet, can all is specified in the geoprocessing environments. In a program, the Geoprocessor object possesses all default environment values. You can get the default value of or change it. The environment values remain in effect within the current geoprocessing session. The following table shows the environment methods the Geoprocessor have to work with:
Method |
Description |
Getenvironmentvalue (Envname) |
Retrieves the value of a environment by name. |
Setenvironmentvalue (Envname, Envvalue) |
Updates the value of a environment by name. |
Resetenvironments () |
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) Form At. |
LoadSettings (sFileName) |
Loads the current settings from the saved file. |
All environment names is passed as strings. Environment names is 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 #]
Public voidSetcoordinatesystem (IGeoProcessor2 GP) {//Set overwrite option to true.Gp. Overwriteoutput =true;//Set workspace environment.Gp. Setenvironmentvalue ("Workspace",@ "C:\data\saltlake.gdb");//Set The output coordinate system environment. Gp. Setenvironmentvalue ("Outputcoordinatesystem", @"C:\Program files\arcgis\desktop10.0\coordinate systems\projected coordinate systems\utm\nad 1983\NAD 1983 UTM Zone 12n.prj "); Ivariantarray parameters =NewVararrayclass (); Parameters. ADD ("Roads"); Parameters. ADD ("Roads_copy"); Gp. Execute ("Copyfeatures_management", parameters,NULL);}
[vb.net]
Public SubSetcoordinatesystem (ByValGp asIGEOPROCESSOR2)' Set overwrite option to true.Gp. Overwriteoutput =True ' Set workspace environment.Gp. Setenvironmentvalue ("Workspace","C:\data\saltlake.gdb")' Set the output coordinate system environment.Gp. Setenvironmentvalue ("Outputcoordinatesystem","C:\Program files\arcgis\desktop10.0\coordinate systems\projected coordinate systems\utm\nad 1983\NAD 1983 UTM Zone 12n.prj ")DimParameters asIvariantarray =NewVararray parameters. ADD ("Roads") parameters. ADD ("Roads_copy") GP. Execute ("Copyfeatures_management", parameters, Nothing)End Sub
The following code example shows how to retrieve and reset environment values:[C #]
//Get The cell Size environment value. Object env = GP. Getenvironmentvalue ("cellsize"); //Reset the environment values to their defaults. Gp. Resetenvironments ();
[vb.net]
' Get The cell Size environment value. Dim as Object = GP. Getenvironmentvalue ("cellsize")' Reset the environment values to their defaults. Gp. Resetenvironments ()
The Listenvironments method returns a list of environments. This method had a wildcard option, and returns an igpenumlist of strings that can is looped through. The following code example shows how to list environments. The method returns all environments this start with the letter "Q" (for example, Qualifedfieldnames).[C #]
Public void Listgeoprocessingenvironments (IGeoprocessor2 GP) { //List All environments This start with the letter Q. igpenumlist environments = GP. Listenvironments ("q*"); //Only one environment starts with Q (qualifiedfieldnames). string env = environments. Next (); Console.WriteLine (env);}
[vb.net]
public sub listgeoprocessingenvironments ( Span class= "KWRD" >byval GP as IGeoProcessor2) ' List all Environm Ents that start with the letter Q. dim environments as igpenumlist = GP. Listenvironments ( "q*" ) dim env as
string = environments.
next ()
' only one environment starts with Q (qualifiedfieldnames). Console.WriteLine (env) env = environments.
next ()
end
sub
After setting several environments using the-Setenvironmentvalue method, you can save them to a XML file, then use them l Ater by loading the settings and the LoadSettings method as shown in the following code example:[C #]
Public voidSaveloadsettings (IGeoProcessor2 GP) {GP. Setenvironmentvalue ("Workspace",@ "C:/data/mydata.gdb"); Gp. Setenvironmentvalue ("Extent"," -3532000, -911000, -3515000, -890000"); Gp. Setenvironmentvalue ("Outputcoordinatesystem","projcs[' nad_1983_utm_zone_11n ', geogcs[' gcs_north_american_1983 ', datum[' d_north_american_1983 ', SPHEROID[' grs_1980 ', 6378137.0,298.257222101]],primem[' Greenwich ', 0.0],unit[' degree ', 0.0174532925199433]],projection[' Transverse_mercator '],parameter[' false_easting ', 500000.0],parameter[' false_northing ', 0.0],PARAMETER[' Central_ Meridian ', -117.0],parameter[' scale_factor ', 0.9996],parameter[' latitude_of_origin ', 0.0],unit[' Meter ', 1.0]] " );//Save environment settings to an XML file. stringSettingsFile =@ "C:\sdk\MyCustomSettings.xml"; Gp. SaveSettings (SettingsFile);//Load previously saved environment settings.Gp. LoadSettings (SettingsFile);ObjectSextent = GP. Getenvironmentvalue ("Workspace");}
[vb.net]
Public SubSaveloadsettings (ByValGp asIGeoProcessor2) GP. Setenvironmentvalue ("Workspace","C:/data/mydata.gdb") GP. Setenvironmentvalue ("Extent"," -3532000, -911000, -3515000, -890000") GP. Setenvironmentvalue ("Outputcoordinatesystem","projcs[' nad_1983_utm_zone_11n ', geogcs[' gcs_north_american_1983 ', datum[' d_north_american_1983 ', SPHEROID[' grs_1980 ', 6378137.0,298.257222101]],primem[' Greenwich ', 0.0],unit[' degree ', 0.0174532925199433]],projection[' Transverse_mercator '],parameter[' false_easting ', 500000.0],parameter[' false_northing ', 0.0],PARAMETER[' Central_ Meridian ', -117.0],parameter[' scale_factor ', 0.9996],parameter[' latitude_of_origin ', 0.0],unit[' Meter ', 1.0]] " )' Save environment settings to an XML file. DimSettingsFile as String="C:\sdk\MyCustomSettings.xml"Gp. SaveSettings (SettingsFile)' Load previously saved environment settings.Gp. LoadSettings (SettingsFile)DimSextent as Object= GP. Getenvironmentvalue ("Workspace")End Sub
Environment Settings Summary tableThe 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 this environment, which explains what the enviro Nment is for and what values can are set for it. Environment names is not case-sensitive in. NET.
Environment name |
Display Name |
Autocommit |
Auto Commit |
Cartographiccoordinatesystem |
Cartographic Coordinate System |
Cellsize |
Cell size |
Coincidentpoints |
Coincident points |
Compression |
Compression |
Configkeyword |
Output CONFIG Keyword |
Derivedprecision |
Precision for Derived coverages |
Extent |
Extent |
Geographictransformations |
Geographic transformations |
Maintainspatialindex |
Maintain Spatial Index |
Mask |
Mask |
Mdomain |
Output M Domain |
Mresolution |
M Resolution |
Mtolerance |
M tolerance |
Newprecision |
Precision for New coverages |
Outputcoordinatesystem |
Output coordinate System |
Outputmflag |
Output has M Values |
Outputzflag |
Output has Z values |
Outputzvalue |
Default Output Z Value |
Projectcompare |
Level of Comparison between Projection Files |
Pyramid |
Pyramid |
Qualifiedfieldnames |
Maintain fully qualified field names |
Randomgenerator |
Random number Generator |
Rasterstatistics |
Raster Statistics |
Referencescale |
Reference Scale |
Scratchworkspace |
Scratch Workspace |
Snapraster |
Snap Raster |
SPATIALGRID1, 2, 3 |
Output Spatial Grid 1, 2, 3 |
Terrainmemoryusage |
Terrain Memory Usage |
Tilesize |
Tile size |
Tinsaveversion |
TIN Storage Version |
Workspace |
Current Workspace |
Xydomain |
Output XY Domain |
Xyresolution |
XY Resolution |
Xytolerance |
XY tolerance |
Zdomain |
Output Z Domain |
Zresolution |
Z Resolution |
Ztolerance |
Z tolerance |
See Also:what is a geoprocessing environment?
A Quick tour of geoprocessing environments
GP Environment Parameter Name list