private static void SelectFeaturesAndRunCopyFeatures()
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 1: Make feature layers using the MakeFeatureLayer tool for the inputs to the SelectByLocation tool.
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the Geoprocessor 
            Geoprocessor GP = new Geoprocessor();

            // Initialize the MakeFeatureLayer tool
            MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();
            makefeaturelayer.in_features = @"C:\data\nfld.gdb\wells";
            makefeaturelayer.out_layer = "Wells_Lyr";
            RunTool(GP, makefeaturelayer, null);

            makefeaturelayer.in_features = @"C:\data\nfld.gdb\bedrock";
            makefeaturelayer.out_layer = "bedrock_Lyr";
            RunTool(GP, makefeaturelayer, null);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 2: Execute SelectLayerByLocation using the feature layers to select all wells that intersect the bedrock geology.
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the SelectLayerByLocation tool
            SelectLayerByLocation SelectByLocation = new SelectLayerByLocation();

            SelectByLocation.in_layer = "Wells_Lyr";
            SelectByLocation.select_features = "bedrock_Lyr";
            SelectByLocation.overlap_type = "INTERSECT";
            RunTool(GP, SelectByLocation, null);

            /////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 3: Execute SelectLayerByAttribute to select all wells that have a well yield > 150 L/min.
            /////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the SelectLayerByAttribute tool
            SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();

            SelectByAttribute.in_layer_or_view = "Wells_Lyr";
            SelectByAttribute.selection_type = "NEW_SELECTION";
            SelectByAttribute.where_clause = "WELL_YIELD > 150";
            RunTool(GP, SelectByAttribute, null);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 4: Execute CopyFeatures tool to create a new feature class of wells with well yield > 150 L/min.
            ////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the CopyFeatures tool
            CopyFeatures CopyFeatures = new CopyFeatures();

            CopyFeatures.in_features = "Wells_Lyr";
            CopyFeatures.out_feature_class = @"C:\data\nfld.gdb\high_yield_wells";


            RunTool(GP, CopyFeatures, null);
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
        private bool CopyFeaturesToFeatureClass(string inLayer, string RecievingFeatureClass)
        {
            CopyFeatures cf = new CopyFeatures();

            cf.in_features       = inLayer;
            cf.out_feature_class = RecievingFeatureClass;
            return(RunProcess(cf, null));
        }
        private static void SelectFeaturesAndRunCopyFeatures()
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 1: Make feature layers using the MakeFeatureLayer tool for the inputs to the SelectByLocation tool.
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the Geoprocessor
            Geoprocessor GP = new Geoprocessor();

            // Initialize the MakeFeatureLayer tool
            MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();

            makefeaturelayer.in_features = @"C:\data\nfld.gdb\wells";
            makefeaturelayer.out_layer   = "Wells_Lyr";
            RunTool(GP, makefeaturelayer, null);

            makefeaturelayer.in_features = @"C:\data\nfld.gdb\bedrock";
            makefeaturelayer.out_layer   = "bedrock_Lyr";
            RunTool(GP, makefeaturelayer, null);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 2: Execute SelectLayerByLocation using the feature layers to select all wells that intersect the bedrock geology.
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the SelectLayerByLocation tool
            SelectLayerByLocation SelectByLocation = new SelectLayerByLocation();

            SelectByLocation.in_layer        = "Wells_Lyr";
            SelectByLocation.select_features = "bedrock_Lyr";
            SelectByLocation.overlap_type    = "INTERSECT";
            RunTool(GP, SelectByLocation, null);

            /////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 3: Execute SelectLayerByAttribute to select all wells that have a well yield > 150 L/min.
            /////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the SelectLayerByAttribute tool
            SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();

            SelectByAttribute.in_layer_or_view = "Wells_Lyr";
            SelectByAttribute.selection_type   = "NEW_SELECTION";
            SelectByAttribute.where_clause     = "WELL_YIELD > 150";
            RunTool(GP, SelectByAttribute, null);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 4: Execute CopyFeatures tool to create a new feature class of wells with well yield > 150 L/min.
            ////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Initialize the CopyFeatures tool
            CopyFeatures CopyFeatures = new CopyFeatures();

            CopyFeatures.in_features       = "Wells_Lyr";
            CopyFeatures.out_feature_class = @"C:\data\nfld.gdb\high_yield_wells";


            RunTool(GP, CopyFeatures, null);
        }
        /// <summary>
        ///     Writes the rows from an feature class to a new feature class.
        /// </summary>
        /// <param name="source">The rows from a feature class to be copied.</param>
        /// <param name="filter">The filter used to create a subset of the data.</param>
        /// <param name="tableName">The name of the table to which the rows will be written.</param>
        /// <param name="workspace">The workspace that will contain the table.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the exported table.
        /// </returns>
        public static IFeatureClass Export(this IFeatureClass source, IQueryFilter filter, string tableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                input = source.MakeView(string.Format("{0}_V", tableName), filter, null, trackCancel, eventHandler);
            }

            CopyFeatures gp = new CopyFeatures();

            gp.in_features       = input;
            gp.out_feature_class = workspace.GetAbsolutePath(tableName);

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                var table = workspace.GetFeatureClass(tableName);
                return(table);
            }

            return(null);
        }
Пример #6
0
        /// <summary>
        /// Copies the feature class.
        /// </summary>
        /// <param name="inputPaths">The input paths.</param>
        /// <param name="outPutPath">The out put path.</param>
        /// <returns></returns>
        public IGeoProcessorResult CopyFeatureClass(string inputPaths, string outPutPath)
        {
            IGeoProcessorResult pGeoProcessroResult = null;

            try
            {
                CopyFeatures pCopyFeature = new CopyFeatures(inputPaths, outPutPath);
                Geoprocessor GP           = new Geoprocessor();
                GP.OverwriteOutput    = true;
                GP.TemporaryMapLayers = false;
                pGeoProcessroResult   = GP.Execute(pCopyFeature, null) as IGeoProcessorResult;

                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGeoProcessroResult.Status.ToString());
                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGeoProcessroResult.GetMessages(0));
                return(pGeoProcessroResult);
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return(null);
            }
        }
Пример #7
0
        /// <summary>
        /// Copies the feature class.
        /// </summary>
        /// <param name="inputPaths">The input paths.</param>
        /// <param name="outPutPath">The out put path.</param>
        /// <returns></returns>
        public IGeoProcessorResult CopyFeatureClass(string inputPaths, string outPutPath)
        {
            IGeoProcessorResult pGeoProcessroResult = null;
            try
            {

                CopyFeatures pCopyFeature = new CopyFeatures(inputPaths, outPutPath);
                Geoprocessor GP = new Geoprocessor();
                GP.OverwriteOutput = true;
                GP.TemporaryMapLayers = false;
                pGeoProcessroResult= GP.Execute(pCopyFeature, null) as IGeoProcessorResult;

                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGeoProcessroResult.Status.ToString());
                //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGeoProcessroResult.GetMessages(0));
                return pGeoProcessroResult;
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return null;
            }
        }
Пример #8
0
        string IDataManager.TnCreateFeatureLayer(string inFeature, string outLayer, string dieukien)
        {
            //num++;
               Geoprocessor GP = new Geoprocessor();
               //MessageBox.Show(dieukien);
               // Intialize the MakeFeatureLayer tool
               //GP.SetEnvironmentValue("workspace", environment);
               MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();

               makefeaturelayer.in_features = inFeature;//this.Mem4DataManager.TempFullPath + inFeature;
               makefeaturelayer.out_layer =string.Format("{0}{1}",_tempPath.TempFullPath,outLayer);
               runTool(GP, makefeaturelayer, null);

               SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();
               GP.ResetEnvironments();
               SelectByAttribute.in_layer_or_view =string.Format("{0}{1}",_tempPath.TempFullPath,outLayer);
               SelectByAttribute.selection_type = "NEW_SELECTION";
               SelectByAttribute.where_clause = dieukien;
               runTool(GP, SelectByAttribute, null);

               CopyFeatures copyFeatures = new CopyFeatures();

               copyFeatures.in_features = outLayer;

               copyFeatures.out_feature_class = _tempPath.TempFullPath + "copiedFeature";

               // Set the output Coordinate System environment
               //GP.SetEnvironmentValue("outputCoordinateSystem",
               //@"C:\Program Files\ArcGIS\Coordinate Systems\Projected Coordinate Systems\UTM\Nad 1983\NAD 1983 UTM Zone 21N.prj");

               //runTool(GP, copyFeatures, null);
               GP.Execute(copyFeatures, null);
               return _tempPath.TempFullPath + "copiedFeature";
        }
Пример #9
0
        /// <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);
        }
Пример #10
0
        void IDataManager.TnCreateFeatureLayer(string inFeature, string outLayer, string dieukien,out string out_featureClass)
        {
            //num++;
               Geoprocessor GP = new Geoprocessor();
               //MessageBox.Show(dieukien);
               // Intialize the MakeFeatureLayer tool
               //GP.SetEnvironmentValue("workspace", environment);
               MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();

               //MessageBox.Show(inFeature);
               makefeaturelayer.in_features = _tempPath.TempFullPath + inFeature; //"C:/tayninh/temp/tempmdb.mdb/tntn_hem_buff_1";
               makefeaturelayer.out_layer = "outlayer";//"C:/tayninh/temp/tempmdb.mdb/ot";//this.Mem4DataManager.TempFullPath+"tn" + outLayer;
               runTool(GP, makefeaturelayer, null);

               SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();
               GP.ResetEnvironments();
               SelectByAttribute.in_layer_or_view = "outlayer";//"C:/tayninh/temp/tempmdb.mdb/ot"; //this.Mem4DataManager.TempFullPath + "tn" + outLayer;
               SelectByAttribute.selection_type = "NEW_SELECTION";
               SelectByAttribute.where_clause = dieukien;
               runTool(GP, SelectByAttribute, null);

               CopyFeatures copyFeatures = new CopyFeatures();

               copyFeatures.in_features = "outlayer";

               copyFeatures.out_feature_class = _tempPath.TempFullPath + "tn" + "cop";// + TnFeatureClassName.HEM_BUFFER_1M_CREATED_FROM_LAYER;

               // Set the output Coordinate System environment
               //GP.SetEnvironmentValue("outputCoordinateSystem",
               //@"C:\Program Files\ArcGIS\Coordinate Systems\Projected Coordinate Systems\UTM\Nad 1983\NAD 1983 UTM Zone 21N.prj");

               //runTool(GP, copyFeatures, null);
               GP.Execute(copyFeatures, null);
               out_featureClass = _tempPath.TempFullPath + "tn" + "cop";// + TnFeatureClassName.HEM_BUFFER_1M_CREATED_FROM_LAYER;
        }
Пример #11
0
        public void ceshiSelect(string shpFileName, string shpFilePath)
        {
            try
            {
                IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
                IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(shpFilePath, 0);
                IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(shpFileName);
                //使要素处于编辑状态
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                IDataset dataset = (IDataset)pFeatureClass;
                //ITable tb = (ITable)pFeatureClass;
                IWorkspace workspace = dataset.Workspace;
                IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
                //workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
                
              //CopyFeatureClass(gp,  selectfeature(pFeatureLayer,"VALUE>5"),@"D:\测试\searchResult.shp");
                //selectfeature(pFeatureLayer, "VALUE>5");
                IQueryFilter pQueryFilter = new QueryFilterClass();
                IFeatureCursor pFeatureCursor = pFeatureLayer.Search(pQueryFilter, true);
                IFeature pFeature = pFeatureCursor.NextFeature();
                // while (pFeature != null)//遍历线图层的name,将线图层中的name和点图层中的lineName加入选择集并对两个选择集进行near,勾选location生成nearX和nearY
                // {
                IFeatureSelection featureSelection = pFeatureLayer as IFeatureSelection;

                //string name = pFeature.get_Value(2).ToString();//线图层的name字段
                pQueryFilter.WhereClause = "VALUE>5";// string.Format("name='{0}'", name);
                featureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);//选择线路名为name的线要素


                IFeatureClass pFeatureclass = featureSelection.SelectionSet as IFeatureClass;

                //这里这样写是不时就选好了那个WhereClause  另一个也是这么执行的 就是想当于你选好的  输入同的参数选择不同的  你稍等我下
                //pFeature = pFeatureCursor.NextFeature();
                //  }
                ESRI.ArcGIS.DataManagementTools.CopyFeatures copyFeatures = new CopyFeatures();
                copyFeatures.in_features = pFeatureclass;// pFeatureLayer.FeatureClass;
                copyFeatures.out_feature_class = @"D:\测试\searchResult3.shp";
                gp.OverwriteOutput = true;
                gp.Execute(copyFeatures, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
               
            }
        }
Пример #12
0
        /// <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;
            }
        }
Пример #13
0
        /// <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;
        }
Пример #14
0
        void ICopyFeatures.CopyUseGeoprocessing(object copiedFeature, object toFeatureClass,string env)
        {
            Geoprocessor gp = new Geoprocessor();
               ESRI.ArcGIS.DataManagementTools.MakeFeatureLayer makeFeatureLayer = new MakeFeatureLayer();
              // makeFeatureLayer.in_features = @"C:\tn\temp\tempmdb.mdb\thua_sau50m_clip";
              // makeFeatureLayer.out_layer = "making_layer";
              // runTool(gp, makeFeatureLayer, null);

              // ESRI.ArcGIS.DataManagementTools.SelectLayerByAttribute select = new SelectLayerByAttribute();

              // select.in_layer_or_view = "making_layer";
              //select.selection_type = "NEW_SELECTION";
              //select.where_clause = "OBJECTID>0";
              //runTool(gp, select, null);

               gp.SetEnvironmentValue("workspace", env);
               ESRI.ArcGIS.DataManagementTools.CopyFeatures tool = new CopyFeatures();
               tool.in_features = @"C:\tn\temp\tempmdb.mdb\thua_sau50m_clip";
               string o=string.Format("{0}/{1}",env,"sde.SDE.thua_giadat_2012");
               MessageBox.Show(string.Format("line 483 DataManager {0}", o));
               tool.out_feature_class = o;
               //tool.config_keyword = "WKB_GEOMETRY";
               runTool(gp, tool, null);
        }
Пример #15
0
        //提取矢量数据
        private void ExtractFeatureClass(string LayerName,Geoprocessor gp, string aimPath, string sourcePath)
        {
            Msg("开始处理..."+LayerName );
            
            try
            {
                
                ESRI.ArcGIS.DataManagementTools.CopyFeatures copyFeature = new CopyFeatures();
                copyFeature.in_features = sourcePath;
                copyFeature.out_feature_class = aimPath + "\\" + LayerName;
                gp.OverwriteOutput = true;
                gp.Execute(copyFeature, null);
                Msg(LayerName + "转换完成!");
                vec_count++;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }

        }
Пример #16
0
 //提取数据
 public void ExtractShpData(Geoprocessor gp, IFeatureClass featureClass, string savePath)
 {
     Msg("开始处理..." + featureClass.AliasName);
     try
     {
         ESRI.ArcGIS.DataManagementTools.CopyFeatures copyFeature = new CopyFeatures();
         copyFeature.in_features = featureClass;
         copyFeature.out_feature_class = savePath + "\\" + featureClass.AliasName;
         gp.OverwriteOutput = true;
         gp.Execute(copyFeature, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     Msg(featureClass.AliasName + "转换完成!");
     vec_count++;
 }
Пример #17
0
 public void CopyFeatureClass(Geoprocessor gp, IFeatureClass pFeatrueClass, string SavaPath)
 {
     try
     {
         ESRI.ArcGIS.DataManagementTools.CopyFeatures copyFeatures = new CopyFeatures();
         copyFeatures.in_features = pFeatrueClass;
         copyFeatures.out_feature_class = SavaPath;
         gp.OverwriteOutput = true;
         gp.Execute(copyFeatures, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #18
0
        //筛选函数
        private IFeatureClass selectfeature(IFeatureLayer featureLayer, string whereclause)
        {
            IFeatureClass featureclass = null;
            try
            {

                IQueryFilter pQueryFilter = new QueryFilterClass();
                IFeatureCursor pFeatureCursor = featureLayer.Search(pQueryFilter, false);
                IFeature pFeature = pFeatureCursor.NextFeature();
                // while (pFeature != null)//遍历线图层的name,将线图层中的name和点图层中的lineName加入选择集并对两个选择集进行near,勾选location生成nearX和nearY
                // {
                IFeatureSelection featureSelection = featureLayer as IFeatureSelection;

                //string name = pFeature.get_Value(2).ToString();//线图层的name字段
                pQueryFilter.WhereClause = whereclause;// string.Format("name='{0}'", name);
                featureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);//选择线路名为name的线要素


                featureLayer = featureSelection as IFeatureLayer;

                //这里这样写是不时就选好了那个WhereClause  另一个也是这么执行的 就是想当于你选好的  输入同的参数选择不同的  你稍等我下
                //pFeature = pFeatureCursor.NextFeature();
                //  }
                ESRI.ArcGIS.DataManagementTools.CopyFeatures copyFeatures = new CopyFeatures();
                copyFeatures.in_features = featureLayer.FeatureClass;
                copyFeatures.out_feature_class = @"D:\测试\searchResult1.shp";
                gp.OverwriteOutput = true;
                gp.Execute(copyFeatures, null);
                //featureclass = featureLayer.FeatureClass;



                return featureclass;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }