Using environment settings

In this topic



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
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.
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#]

public void setCoordinateSystem(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 = new VarArrayClass();
parameters.Add("roads");
parameters.Add("roads_copy"); gp.Execute("CopyFeatures_management", parameters, null);
}

[VB.NET]

Public Sub setCoordinateSystem(ByVal gp As IGeoProcessor2)

    '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") Dim parameters As IVariantArray = New VarArray
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 env As Object = GP.GetEnvironmentValue("cellsize") ' Reset the environment values to their defaults.
GP.ResetEnvironments()
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#]

public void ListGeoprocessingEnvironments(IGeoprocessor2 gp)
{
// List all environments that 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(ByVal gp As IGeoProcessor2)

    'List all environments 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 an XML file, then use them later by loading the settings with the LoadSettings method as shown in the following code example:

[C#]

public void SaveLoadSettings(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.
string settingsFile = @"C:\sdk\MyCustomSettings.xml";
gp.SaveSettings(settingsFile); // Load previously saved environment settings.
gp.LoadSettings(settingsFile);
object sExtent = gp.GetEnvironmentValue("workspace");
}

[VB.NET]

Public Sub SaveLoadSettings(ByVal gp As IGeoProcessor2)

    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.
Dim settingsFile As String = "C:\sdk\MyCustomSettings.xml"
gp.SaveSettings(settingsFile) ' Load previously saved environment settings.
gp.LoadSettings(settingsFile)
Dim sExtent As Object = gp.GetEnvironmentValue("workspace") End Sub

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

See Also:

What is a geoprocessing environment?
A quick tour of geoprocessing environments

 
 

GP 环境参数名称列表的更多相关文章

  1. GP工具环境变量名称列表

    帮助地址:http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Using_environment_settings/ ...

  2. python+tushare获取A股所有股票代码和名称列表

    接口:stock_basic 描述:获取基础信息数据,包括股票代码.名称.上市日期.退市日期等 注:tushare模块下载和安装教程,请查阅我之前的文章 输入参数 名称      |      类型  ...

  3. 清理SQL Server服务器名称列表

    SQL2008: C:\Users\TQ\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin SQ ...

  4. Gof-23种设计模式名称列表

    工欲善其事,必先利其器. 在真正使用设计模式之前,必须知道各个设计模式对应的场景.设计模式是针对某种固定的场景下产生的固定解决方案.只有明确的场景,才会有明确的设计方式和方法. 设计模式全集: Abs ...

  5. python 获取excel文件内sheet名称列表

    xl = pd.ExcelFile('foo.xls') xl.sheet_names # see all sheet names xl.parse(sheet_name) # read a spec ...

  6. arcgis python ListEnvironments 函数可返回地理处理环境名称列表。

    import arcpy environments = arcpy.ListEnvironments() # Sort the environment names environments.sort( ...

  7. ArcGIS 10.1 发布使用ArcEngine自定义的GP服务

    1. 新建立GP模型 在VS2010中新建一个普通的程序及,引入ArcEngine相关的dll.在该DLL中定义一个或多个GP类和一个GP工厂类.GP类要继承IGPFunction2接口,GP工厂类要 ...

  8. ArcGIS Server GP服务使用常见错误总结

    ArcGIS GP服务问题列表 输入参数错误 在使用GP服务时,从创建模型到发布服务,再到调用服务,整个过程都需要注意输入参数和输出参数的问题.GP服务支持的输入和输出参数可详见 http://hel ...

  9. Python-7 列表list

    #1 创建列表.向列表中添加元素 1) 列表名称.append(*) 2) 列表名称.extend([*,*,...]) 3) 列表名称.insert(位置,*) member = ['小甲鱼','小 ...

随机推荐

  1. Ubuntu gcc缺失问题

    在安装redis过程中,需要使用make编译源码,但发现linux中缺失gcc,系统为Ubuntu12. 一般情况下,可使用sudo apt-get install gcc或者sudo apt-get ...

  2. JAVA 布尔型的应用

    定义一个布尔类型的flag, 只是当做一个开关的意思.先定义一个标记,然后根据一些条件给这个flag赋不同的值,最后,再根据这个flag不同的值,做不同的处理.   public static voi ...

  3. Hibernate的面试题

    1.Hibernate工作原理和为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3.打开Session 4.创建事务Transation 5.持 ...

  4. SpringMvc静态资源加载出错

    使用mvc:resource配置 web.xml配置是rest风格的/ 服务器启动没问题 访问地址是报404 另外用了default-servlet的方法加载,服务器启动没错,jsp页面加载静态资源要 ...

  5. struts2 配置拦截器

    第一步:继承MethodFilterInterceptor写自己的自定义拦截器 import org.apache.struts2.ServletActionContext; import com.o ...

  6. C#异常语句

    try: 用于检查发生的异常,并帮助发送任何可能的异常. catch: 以控制权更大的方式处理错误,可以有多个catch子句. finally :无论是否引发了异常,finally的代码块都将被执行. ...

  7. js点击空白处弹窗消失

    $(document).mousedown(function(e){ var _list = $('#pop'); if(!_list.is(e.target) && _list.ha ...

  8. Surprise团队第四周项目总结

    Surprise团队第四周项目总结 项目进展 这周我们小组的项目在上周的基础上进行了补充,主要注重在注册登录界面的改进优化与美观,以及关于人计算法的学习与初步实现. 我们小组针对上次APP中界面出现的 ...

  9. winfrom 限制文本框小数点后两位

    private void numWeight_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsNumber(e.KeyChar) | ...

  10. TYVJ 4354 多重背包二进制优化

    直接放代码了 #include <cstdio> #include <cstring> #include <algorithm> using namespace s ...