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. C#设计模式系列:命令模式(Command)

    1.命令模式简介 1.1>.定义 命令模式的目的是解除命令发出者和接收者之间的紧密耦合关系,使二者相对独立,有利于程序的并行开发和代码的维护.命令模式的核心思想是将请求封装为一个对象,将其作为命 ...

  2. Unity3D移植到Windows phone8 遇到的点点滴滴

    LitJson.JsonMapper:Type.GetInterface(String)=>Type.GetInterface(String,Boolean) protobuf应位于Assets ...

  3. java的栈图形演示

    import java.awt.*; import javax.swing.*; import java.awt.event.*; /* 指示发生了组件定义的动作的语义事件.当特定于组件的动作(比如被 ...

  4. 设计数据库字段或者java中使用boolean型时需谨慎

    boolean型变量只有两个值 false和true,我们在设计数据库字段时或者定义java变量时会使用boolean,通常情况下开关类的变量使用无可非议,但请一定要考虑到扩展性. 使用前请仔细考虑一 ...

  5. JavaMail发送邮件的笔记及Demo

    最近碰到一个需求,就是注册用户时候需要向用户发送激活邮箱,于是照着网上搜来的demo自己试着运行了一下,发件时我用的是网易163邮箱,收件时用QQ邮箱,运行后报了一个错误: 网络上搜索解决方式,多次尝 ...

  6. Josephus环问题

    约瑟夫环问题 问题描述: Josephus问题可以描述为如下的一个游戏:N个人编号从1到N,围坐成一个圆圈,从1号开始传递一个热土豆,经过M次传递后拿着土豆的人离开圈子,由坐在离开的人的后面的人拿起热 ...

  7. PHP实现实现数字补零格式化

    在接支付SDK的时候,第三方回调处理时需要IP,并且IP的需求是:去掉点号,补零到每地址段3位, 如:192168000001 先看看我的实现: <?php $IP = explode ( '. ...

  8. springMVC学习笔记(一)-----springMVC原理

    一.什么是springmvc springMVC是spring框架的一个模块,springMVC和spring无需通过中间整合层进行开发. springMVC是一个基于mvc的web框架. Sprin ...

  9. jQuery-1.9.1源码分析系列(一)整体架构续

    这一节主要是jQuery中最基础的几个东东 2.    jQuery的几个基础属性和函数 a. jQuery.noConflict函数详解 在jQuery初始化的时候保存了外部的$和jQuery _j ...

  10. Centos6 yum安装openldap+phpldapadmin+TLS+双主配置

    原文地址:http://54im.com/openldap/centos-6-yum-install-openldap-phpldapadmin-tls-%E5%8F%8C%E4%B8%BB%E9%8 ...