当前位置: 首页>>代码示例>>C#>>正文


C# Geoprocessor.SetEnvironmentValue方法代码示例

本文整理汇总了C#中Geoprocessor.SetEnvironmentValue方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.SetEnvironmentValue方法的具体用法?C# Geoprocessor.SetEnvironmentValue怎么用?C# Geoprocessor.SetEnvironmentValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geoprocessor的用法示例。


在下文中一共展示了Geoprocessor.SetEnvironmentValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: using

        void IClip.ClipByLayerFileInsideSde(object in_feature, string in_layer_file_path, object clip_feature, string clip_layer_file_path, string out_feature)
        {
            using (ComReleaser releaser = new ComReleaser())
            {
                try
                {
                    Geoprocessor gp = new Geoprocessor();
                    IDataManager _dataManager = new DataManager(this._environment);
                    ESRI.ArcGIS.AnalysisTools.Clip clipTool = new ESRI.ArcGIS.AnalysisTools.Clip();

                    //releaser.ManageLifetime(gp);
                    //releaser.ManageLifetime(clipTool);
                    //IVariantArray param = new VarArrayClass();

                    string inlayer = string.Format("{0}.lyr", in_layer_file_path);
                    string cliplayer = string.Format("{0}.lyr", clip_layer_file_path);
                    //MessageBox.Show(string.Format("line 61 GExtractTool in={0}, clip={1}", inlayer, cliplayer));
                    _dataManager.SaveToLayerFile((ILayer)in_feature, inlayer);
                    _dataManager.SaveToLayerFile((ILayer)clip_feature, cliplayer);

                    //MessageBox.Show(((IFeatureLayer)in_feature).FeatureClass.AliasName);
                    gp.SetEnvironmentValue("workspace", this._environment);
                    clipTool.in_features = inlayer;
                    clipTool.clip_features = cliplayer;
                    clipTool.out_feature_class = out_feature;//string.Format("{0}{1}", this._temFullPath, out_feature);//"C:\\tayninh\\temp\\tempmdb.mdb\\" + out_feature;

                    runTool(gp, clipTool, null);
                }
                catch (Exception err) { MessageBox.Show("loi clip: " + err.ToString()); }
            }
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:31,代码来源:GExtractTool.cs

示例2: Geoprocessor

 void IAppend.Append(IFeatureClass fcSource, IFeatureClass fcTarget)
 {
     Geoprocessor gp = new Geoprocessor();
        ESRI.ArcGIS.DataManagementTools.Append pAppend = new ESRI.ArcGIS.DataManagementTools.Append(fcSource, fcTarget);
        gp.SetEnvironmentValue("workspace",this._environment);
        pAppend.schema_type = "NO_TEST";
        runTool(gp, pAppend, null);
 }
开发者ID:truonghinh,项目名称:TnX,代码行数:8,代码来源:DataManager.cs

示例3: Geoprocessor

 void IBuffer.BufferInsideSde(string in_features, string out_feature, object distance)
 {
     Geoprocessor gp = new Geoprocessor();
     ESRI.ArcGIS.AnalysisTools.Buffer bufferTool = new ESRI.ArcGIS.AnalysisTools.Buffer();
     //_environment = "Database Connections/Connection to HT-LAPTOP.sde";
     //MessageBox.Show("TnBuffer-line:85--environment: " + _environment);
     gp.SetEnvironmentValue("workspace", _environment);
     bufferTool.in_features = in_features;
     bufferTool.out_feature_class = out_feature;
     bufferTool.buffer_distance_or_field = distance;
     runTool(gp, bufferTool, null);
 }
开发者ID:truonghinh,项目名称:TnX,代码行数:12,代码来源:GProximityTool.cs

示例4: Excute

        public void Excute(object inputFeatureClass, object targetFeatureClass)
        {
            try
            {
                Geoprocessor gp = new Geoprocessor();
                ESRI.ArcGIS.DataManagementTools.Append appendTool = new ESRI.ArcGIS.DataManagementTools.Append();
                //IVariantArray param = new VarArrayClass();
                gp.SetEnvironmentValue("workspace", this._environment);
                appendTool.inputs = inputFeatureClass;
                appendTool.target = targetFeatureClass;
                //appendTool.out_feature_class = string.Format("{0}{1}", this._temFullPath, out_feature);//"C:\\tayninh\\temp\\tempmdb.mdb\\" + out_feature;

                runTool(gp, appendTool, null);
            }
            catch (Exception err) { MessageBox.Show("loi append: " + err.ToString()); }
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:16,代码来源:GAppend.cs

示例5: Geoprocessor

        void IClip.Clip(object in_feature, object clip_feature, string out_feature)
        {
            try
            {
                Geoprocessor gp = new Geoprocessor();
                ESRI.ArcGIS.AnalysisTools.Clip clipTool = new ESRI.ArcGIS.AnalysisTools.Clip();
                //IVariantArray param = new VarArrayClass();
                gp.SetEnvironmentValue("workspace", this._environment);
                //MessageBox.Show(((IFeatureLayer)in_feature).FeatureClass.AliasName);
                clipTool.in_features = in_feature;
                clipTool.clip_features = clip_feature;
                clipTool.out_feature_class = string.Format("{0}",out_feature);//"C:\\tayninh\\temp\\tempmdb.mdb\\" + out_feature;

                runTool(gp, clipTool, null);
            }
            catch (Exception err) { MessageBox.Show("loi clip: " + err.ToString()); }
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:17,代码来源:GExtractTool.cs

示例6: FormProcessing

        public FormProcessing()
        {
            InitializeComponent();

            //Set up ListView control
            listView1.Columns.Add("Event", 200, HorizontalAlignment.Left);
            listView1.Columns.Add("Message", 1000, HorizontalAlignment.Left);
            listView1.SmallImageList = imageList1;

            // Set up Geoprocessor
            _gp = new Geoprocessor();
            string outputDir = @"e:\data\";
            _gp.SetEnvironmentValue("workspace", outputDir);
            _gp.OverwriteOutput = true;
            // GP Events
            _gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(_gp_ToolExecuted);
            _gp.ToolExecuting += new EventHandler<ToolExecutingEventArgs>(_gp_ToolExecuting);
            _gp.ProgressChanged += new EventHandler<ESRI.ArcGIS.Geoprocessor.ProgressChangedEventArgs>(_gp_ProgressChanged);
            _gp.MessagesCreated += new EventHandler<MessagesCreatedEventArgs>(_gp_MessagesCreated);

            // Menu Events
            loadDataToolStripMenuItem.Click += new EventHandler(loadDataToolStripMenuItem_Click);
        }
开发者ID:weigiser,项目名称:AOProjects,代码行数:23,代码来源:FormProcessing.cs

示例7: RunGPForm

    /// <summary>
    /// Initializes a new instance of the RunGPForm class which represents the ArcGIS Engine application.
    /// The constructor is used to perform setup: the ListViewControl is configured, a new Geoprocessor
    /// object is created, the output result directory is specified and event handlers created in order
    /// to listen to geoprocessing events. A helper method called SetupMap is called to create, add and
    /// symbolize the layers used by the application.
    /// </summary>
    public RunGPForm()
    {
      InitializeComponent();

      //Set up ListView control
      listView1.Columns.Add("Event", 200, HorizontalAlignment.Left);  
      listView1.Columns.Add("Message", 1000, HorizontalAlignment.Left);
      //The image list component contains the icons used in the ListView control
      listView1.SmallImageList = imageList1;

      //Create a Geoprocessor object and associated event handlers which will be fired during tool execution
      _gp = new Geoprocessor();
      //All results will be written to the users TEMP folder
      string outputDir = System.Environment.GetEnvironmentVariable("TEMP");
      _gp.SetEnvironmentValue("workspace", outputDir);
      _gp.OverwriteOutput = true;
      _gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(_gp_ToolExecuted);
      _gp.ProgressChanged += new EventHandler<ESRI.ArcGIS.Geoprocessor.ProgressChangedEventArgs>(_gp_ProgressChanged);
      _gp.MessagesCreated += new EventHandler<MessagesCreatedEventArgs>(_gp_MessagesCreated);
      _gp.ToolExecuting += new EventHandler<ToolExecutingEventArgs>(_gp_ToolExecuting);

      //Add layers to the map, select a city, zoom in on it
      SetupMap();
    }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:31,代码来源:RunGPForm.cs

示例8: CreateContours

        /// <summary>
        /// 生成等值线
        /// </summary>
        /// <params name="targetworkspace"></params>
        /// <params name="nameOftargetFeatureClass"></params>
        /// <params name="sLayerAliasName"></params>
        private bool CreateContours(IWorkspace targetworkspace, string nameOftargetFeatureClass,
            string sLayerAliasName, string extent, ref string failInfo)
        {
            double douElevation;

            //设置一个最小值
            progressBarControl1.Properties.Minimum = 0;
            //设置一个最大值
            progressBarControl1.Properties.Maximum = 6;
            //设置步长,即每次增加的数
            progressBarControl1.Properties.Step = 1;
            //设置进度条的样式
            progressBarControl1.Properties.ProgressViewStyle = ProgressViewStyle.Solid;
            progressBarControl1.Position = 0;

            try
            {
                Geoprocessor GP = new Geoprocessor();

                if (withIn(m_strDataFilePath) == false)
                    return false;
                if (TB_Interval.Text == "")
                {
                    MessageBox.Show("请输入正确的等高距!", "提示!");
                    return false;
                }
                if (double.TryParse(TB_Interval.Text.Trim(), out douElevation))
                { }
                else
                {
                    TB_Interval.Text = null;
                    MessageBox.Show("请输入正确的等高距!", "提示!");
                    return false;
                }

                string featurOut = m_MakeContoursFolder + "\\Cont.shp";
                int k = 0;
                while (File.Exists(featurOut))
                {
                    k++;
                    featurOut = m_MakeContoursFolder + "\\Cont" + k.ToString() + ".shp";

                }
                int countCont = Directory.GetFiles(m_MakeContoursFolder, "Cont*").Length;
                if (countCont > 0)
                {
                    featurOut = m_MakeContoursFolder + "\\Cont" + countCont.ToString() + ".shp";
                }
                if (DrawContours.ConvertASCIIDescretePoint2FeatureClass(GP, m_strDataFilePath, featurOut) == false)
                    return false;
                //执行步长
                this.progressBarControl1.PerformStep();

                string ContourRaster = m_MakeContoursFolder + "\\Spline";
                //string ContourRaster = m_MakeContoursFolder + "\\" + nameOftargetFeatureClass + "_Render";
                if (extent != "")//右上左下  xmax  ymax  xmin  ymin
                    GP.SetEnvironmentValue("Extent", extent);
                bool suc = false;
                string sRasterLayerAliasName = sLayerAliasName + "渲染图";
                ILayer rsLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, sRasterLayerAliasName);
                if (rsLayer != null)
                {
                    DataEditCommon.g_pMap.DeleteLayer(rsLayer);
                }
                if (Directory.Exists(ContourRaster))
                {
                    try
                    {
                        Directory.Delete(ContourRaster, true);
                    }
                    catch
                    {
                        k = 1;
                        while (Directory.Exists(ContourRaster))
                        {
                            ContourRaster = m_MakeContoursFolder + "\\Spline" + k.ToString();
                            k++;
                        }
                    }
                }
                switch (CB_InterpolationMethod.Text)
                {
                    case "样条函数插值法":
                        suc = DrawContours.Interpolate2RasterSpline(GP, featurOut, ContourRaster, CB_SplineType.Text);
                        break;
                    case "自然邻域插值法":
                        suc = DrawContours.Interpolate2RasterNN(GP, featurOut, ContourRaster);
                        break;
                    case "克里格插值法":
                        suc = DrawContours.Interpolate2RasterKriging(GP, featurOut, ContourRaster,
                            CB_semiVariogramProp.Text, CB_searchRadiusProp.Text);
                        break;
                    case "反距离权重插值法":
                        suc = DrawContours.Interpolate2RasterIDW(GP, featurOut, ContourRaster);
//.........这里部分代码省略.........
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:101,代码来源:MakeContours.cs

示例9: listRasters

        public void listRasters(Geoprocessor GP)
        {
            // List all TIFF files in the workspace and build pyramids.
            GP.SetEnvironmentValue("workspace", @"C:\Corey\Ccm\results");
            IGpEnumList rasters = GP.ListRasters("*", "TIFF");
            string raster = rasters.Next();

            // Intialize the BuildPyramids tool.
            BuildPyramids pyramids = new BuildPyramids();

            while (raster != "")
            {

                // Set input raster dataset.
                pyramids.in_raster_dataset = raster;
                GP.Execute(pyramids, null);
                raster = rasters.Next();
            }
        }
开发者ID:dmuthami,项目名称:Meru_Water,代码行数:19,代码来源:ListData.cs

示例10: BatchCopyFeatureClass

        /// <summary>
        /// Batches the copy feature class.
        /// </summary>
        /// <param name="workspacePath">The workspace path.</param>
        /// <param name="sourceDatasetName">Name of the source dataset.</param>
        /// <param name="Layerfilter">The layerfilter.</param>
        /// <param name="targetPath">The target path.</param>
        /// <param name="targetDatasetName">Name of the target dataset.</param>
        /// <returns></returns>
        public bool BatchCopyFeatureClass(string workspacePath, string sourceDatasetName,List<string> Layerfilter, string targetPath
                           ,string targetDatasetName)
        {
            try
            {
                Geoprocessor pGP = new Geoprocessor();
                List<string> featclsList = new List<string>();
                pGP.OverwriteOutput = true;
                pGP.SetEnvironmentValue("workspace", (object)workspacePath);

                IGpEnumList pFeatDatasetList = pGP.ListDatasets("", "");

                IGpEnumList pFeatClsList = null;

                string strDatasetName = pFeatDatasetList.Next();

                if (strDatasetName != "")
                {
                    while (strDatasetName !="")
                    {
                        pFeatClsList = pGP.ListFeatureClasses("", "", strDatasetName);

                        string strName = pFeatClsList.Next();
                        while (strName != "")
                        {
                            if (Layerfilter.Contains(strName.ToUpper()) && !featclsList.Contains(strName))
                            {
                                featclsList.Add(strName.ToUpper());
                            }
                            strName = pFeatClsList.Next();
                        }
                        strDatasetName = pFeatDatasetList.Next();
                    }
                }
                else
                {
                    pFeatClsList = pGP.ListFeatureClasses("", "", "");
                    string strName = pFeatClsList.Next();
                    while (strName != "")
                    {
                        if (Layerfilter.Contains(strName.ToUpper()) && !featclsList.Contains(strName))
                        {
                            featclsList.Add(strName.ToUpper());
                        }
                        strName = pFeatClsList.Next();
                    }
                }

                if (featclsList.Count == 0) return false;

                CopyFeatures pCopyFeature = new CopyFeatures();

                foreach (string str in featclsList)
                {
                    if (string.IsNullOrEmpty(strDatasetName))
                    {
                        pCopyFeature.in_features = string.Format("{0}\\{1}", workspacePath, str);
                    }
                    else
                    {
                        pCopyFeature.in_features = string.Format("{0}\\{1}\\{2}", workspacePath, strDatasetName, str);
                    }
                    pCopyFeature.out_feature_class = string.Format("{0}\\{1}\\{2}_Standard", targetPath, targetDatasetName, str);
                    pGP.Execute(pCopyFeature, null);
                    object obj = null;
                    //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGP.GetMessages(ref obj));
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return false;
            }
            return true;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:85,代码来源:GPTool.cs

示例11: CopyFeatureClass

        /// <summary>
        /// Copies the feature class.
        /// </summary>
        /// <param name="inputPaths">The input paths.</param>
        /// <param name="outPutPath">The out put path.</param>
        /// <param name="outputHasMValues"></param>
        /// <param name="outputHasZValues"></param>
        /// <returns></returns>
        public IGeoProcessorResult CopyFeatureClass(string inputPaths, string outPutPath, bool outputHasZValues, bool outputHasMValues)
        {
            try
            {
                CopyFeatures pCopyFeature = new CopyFeatures(inputPaths, outPutPath);
                Geoprocessor GP = new Geoprocessor();
                GP.OverwriteOutput = true;
                GP.TemporaryMapLayers = false;

                if (outputHasZValues)
                {
                    object obj = GP.GetEnvironmentValue("OutputZFlag"); //设置Output has Z Values
                    GP.SetEnvironmentValue("OutputZFlag", "DEFAULT");
                }

                if (outputHasMValues)
                {
                    object obj = GP.GetEnvironmentValue("OutputMFlag");                    //设置Output has M Values
                    GP.SetEnvironmentValue("OutputMFlag", "DEFAULT");
                }

                IGeoProcessorResult result = GP.Execute(pCopyFeature, null) as IGeoProcessorResult;
                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.Status.ToString());
                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.GetMessages(0));
                return result;
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return null;
            }
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:41,代码来源:GPTool.cs

示例12: ConvertPersonalGeodatabaseToFileGeodatabase

        private static void ConvertPersonalGeodatabaseToFileGeodatabase()
        {
            // Initialize the Geoprocessor
            Geoprocessor geoprocessor = new Geoprocessor();

            // Allow for the overwriting of file geodatabases, if they previously exist.
            geoprocessor.OverwriteOutput = true;

            // Set the workspace to a folder containing personal geodatabases.
            geoprocessor.SetEnvironmentValue("workspace", @"C:\data");

            // Identify personal geodatabases.
            IGpEnumList workspaces = geoprocessor.ListWorkspaces("*", "Access");
            string workspace = workspaces.Next();
            while (workspace != "")
            {
                // Set workspace to current personal geodatabase
                geoprocessor.SetEnvironmentValue("workspace", workspace);

                // Create a file geodatabase with the same name as the personal geodatabase
                string gdbname = System.IO.Path.GetFileName(workspace).Replace(".mdb", "");
                string dirname = System.IO.Path.GetDirectoryName(workspace);

                // Execute CreateFileGDB tool
                CreateFileGDB createFileGDBTool = new CreateFileGDB(dirname, gdbname + ".gdb");
                geoprocessor.Execute(createFileGDBTool, null);

                // Initialize the Copy Tool
                Copy copyTool = new Copy();

                // Identify feature classes and copy to file geodatabase
                IGpEnumList fcs = geoprocessor.ListFeatureClasses("", "", "");
                string fc = fcs.Next();
                while (fc != "")
                {
                    Console.WriteLine("Copying " + fc + " to " + gdbname + ".gdb");
                    copyTool.in_data = fc;
                    copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fc;
                    geoprocessor.Execute(copyTool, null);
                    fc = fcs.Next();
                }

                // Identify feature datasets and copy to file geodatabase
                IGpEnumList fds = geoprocessor.ListDatasets("", "");
                string fd = fds.Next();
                while (fd != "")
                {
                    Console.WriteLine("Copying " + fd + " to " + gdbname + ".gdb");
                    copyTool.in_data = fd;
                    copyTool.data_type = "FeatureDataset";
                    copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fd;
                    try
                    {
                        geoprocessor.Execute(copyTool, null);
                    }
                    catch (Exception ex)
                    {
                        object sev = null;
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                    fd = fds.Next();
                }

                // Identify tables and copy to file geodatabase
                IGpEnumList tbls = geoprocessor.ListTables("", "");
                string tbl = tbls.Next();
                while (tbl != "")
                {
                    Console.WriteLine("Copying " + tbl + " to " + gdbname + ".gdb");
                    copyTool.in_data = tbl;
                    copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + tbl;
                    geoprocessor.Execute(copyTool, null);
                    tbl = tbls.Next();
                }

                workspace = workspaces.Next();
            }
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:78,代码来源:ToFileGDB.cs


注:本文中的Geoprocessor.SetEnvironmentValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。