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
GetEnvironmentValue(envName) Retrieves the value of an environment by name.
SetEnvironmentValue(envName, envValue) Updates the value of an 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) 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

 
 
作者: cglnet
本文版权归cglNet和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.

arcgis arcengine Using environment settings的更多相关文章

  1. Arcgis, ArcEngine, Arcgis Server使用开发汇总 索引

    ArcGIS系列软件license及安装: Arcgis SDE10.1 和 Arcgis server10.1的授权文件license tnt_esri.dat Arcgis8.1安装license ...

  2. c# 调用ArcEngine的GP工具

    转自原文c# 调用ArcEngine的GP工具,AE调用GP工具 IAoInitialize m_AoInitialize = new AoInitializeClass(); esriLicense ...

  3. ArcGIS教程:加权叠加

    摘要 使用经常使用測量比例叠加多个栅格数据,并依据各栅格数据的重要性分配权重. 插图 插图中,两个输入栅格已又一次分类为 1 至 3 三种公共測量级别.为每一个栅格均分配了一个影响百分比.这些像元值与 ...

  4. ArcGIS教程:创建特征

    摘要 创建由输入样本数据和一组栅格波段定义的类的 ASCII 特征文件. 使用方法 · 输出特征文件应使用扩展名 .gsg. · 输入栅格波段和输入栅格或要素样本数据必须具有重叠范围.将仅为公共区域计 ...

  5. AE(ArcEngine)定制工具Tool工具箱

    using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServi ...

  6. How to work with the snap environment

    How to work with the snap environment SummaryThe snap environment manages snap agents and snap toler ...

  7. arcgis mpk 打包地图 (数据管理)

    摘要 来自:http://help.arcgis.com/zh-cn/arcgisdesktop/10.0/help/index.html#/na/0017000000q5000000/ 对地图文档以 ...

  8. ArcGIS教程:编辑特征

    摘要 通过合并.又一次编号和删除类特征来编辑和更新特征文件. 使用方法 · 编辑特征工具同意您通过下面全部操作或某一操作来改动现有特征文件: 合并一组特征类 又一次编号特征类 ID 删除不须要的特征 ...

  9. arcgis影像批量裁剪代码

    # -*- coding:utf-8 -*- # Name: ExtractByMask_Ex_02.py # Description: Extracts the cells of a raster ...

随机推荐

  1. ClickOnce部署(4):下载多个安装包

    有时候,我们可能会一次性发布多个安装包,当然在网页上多加几个链接让用户逐个安装也是可取的.不过,也可以弄得更方便些,即用户先安装一个,作为一个"引导程序",然后通过这个程序去下载安 ...

  2. Qt Undo Framework Demo

    Qt Undo Framework Demo eryar@163.com Abstract. Qt’s Undo Framework is an implementation of the Comma ...

  3. Minor【 PHP框架】2.第一个应用与请求的生命周期

    框架Github地址:github.com/Orlion/Minor (如果觉得还不错给个star哦(^-^)V) 框架作者: Orlion 知乎:https://www.zhihu.com/peop ...

  4. SubSonic3.0.0.4.2源码包与调用Dll

    ================================================================ 名    称:SubSonic插件版    本:3.0.0.4.2最后 ...

  5. geotrellis使用(十八)导入多波段Tiff、读取多波段Tile

    Geotrellis系列文章链接地址http://www.cnblogs.com/shoufengwei/p/5619419.html 目录 前言 多波段数据导入 读取多波段瓦片 提取单波段 总结 一 ...

  6. JavaScript 框架设计

    JavaScript 高级框架设计 在现在,jQuery等框架已经非常完美,以致于常常忽略了JavaScript原生开发,但是这是非常重要的. 所以,我打算写一个简单的框架,两个目的 熟练框架的思想 ...

  7. 介绍一个很爽的 php 字符串特定检索函数---strpos()

    大家在用 php 开发的时候 是否 有遇到过,对于一个获取的字符串,如果想要特定检测它是否 含有某个特定的字符或者子字符串,总是找不到好方法,或者根本做不到,迫于无奈而使用foreach. 函数: s ...

  8. 弹窗层效果的实现(非jQuery实现)

    要想实现弹窗的效果,首先应该创建一个覆盖层maskLayer,以及一个显示层presentLayer. 其次,每次弹窗时(除首次弹窗外),maskLayer的显示以及隐藏不应该导致文档流的reflow ...

  9. Ftp上传下载 C#

    public class MyFtpClass { private readonly string _destIp; private readonly string _userName; privat ...

  10. Date, TimeZone, MongoDB, java中date的时区问题

    打印new Date(),Fri Aug 12 13:37:51 CST 2016. 显示Asia/Shanghai的时区,但是date toString 的时区简写却是CST.更坑爹的是,Googl ...