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);
        }
        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);
        }
Ejemplo n.º 3
0
        public static void select_layer_by_att(Geoprocessor gp, string in_layer, string where, string selection_type)
        {
            SelectLayerByAttribute SelectLayetByAtt = new SelectLayerByAttribute();

            SelectLayetByAtt.in_layer_or_view = in_layer;
            SelectLayetByAtt.selection_type   = selection_type;
            SelectLayetByAtt.where_clause     = where;
            gp.Execute(SelectLayetByAtt, null);
        }
Ejemplo n.º 4
0
        private IFeatureClass SelectByValue(string inLayerName, string whereClause)
        {
            IQueryFilter qf = new QueryFilterClass();

            qf.WhereClause = whereClause;
            SelectLayerByAttribute selectByValue = new SelectLayerByAttribute();

            selectByValue.in_layer_or_view = inLayerName;
            selectByValue.selection_type   = "NEW_SELECTION";
            selectByValue.where_clause     = whereClause;
            return(this.RunProcessGetFeatureClass(selectByValue, null));
        }
Ejemplo n.º 5
0
        private void SelectByValue(string inLayerName, string whereClause, string outLayerName)
        {
            IQueryFilter qf = new QueryFilterClass();

            qf.WhereClause = whereClause;
            SelectLayerByAttribute selectByValue = new SelectLayerByAttribute();

            selectByValue.in_layer_or_view  = inLayerName;
            selectByValue.selection_type    = "NEW_SELECTION";
            selectByValue.where_clause      = whereClause;
            selectByValue.out_layer_or_view = outLayerName;

            this.RunProcess(selectByValue, null);
            this.CopyFeaturesToFeatureClass(selectLayer, outLayerName);
        }
        /// <summary>
        /// 3.根据级别提取到不同要素类(m_MiddleWorkspace)
        /// 进行初步合并,合并距离由区域道路宽度确定
        /// </summary>
        private void ExtractAggregate(double[] gradeNodes, double distThreld)
        {
            //1.Select the feature in the interval, lik score in [low,high)
            SelectLayerByAttribute selectbyattriTool = new SelectLayerByAttribute();
            selectbyattriTool.in_layer_or_view = m_FeaLyr;
            selectbyattriTool.selection_type = "NEW_SELECTION";

            //2.Aggregating for the selected features and save it in aggregation folder
            AggregatePolygons aggregateTool = new AggregatePolygons();
            aggregateTool.in_features = m_FeaLyr;
            aggregateTool.aggregation_distance = distThreld;
            aggregateTool.orthogonality_option = "ORTHOGONAL";

            try
            {
                for (int i = 0; i < gradeNodes.Length - 1; i++)
                {
                    m_GPProcess.Clear();

                    double scorenode_low = gradeNodes[i];
                    double scorenode_high = gradeNodes[i + 1];
                    string clause = "";
                    if (i == gradeNodes.Length - 2)
                        clause = m_PartitionField + " >= " + scorenode_low.ToString() + " AND " + m_PartitionField + " <= " + scorenode_high.ToString();
                    else
                        clause = m_PartitionField + " >= " + scorenode_low.ToString() + " AND " + m_PartitionField + " < " + scorenode_high.ToString();
                    selectbyattriTool.where_clause = clause;

                    string outname = "aggregation" + i.ToString();
                    aggregateTool.out_feature_class = outname;

                    if (PhaseExcutedEvent != null)
                        PhaseExcutedEvent(this, "Process on grade " + Convert.ToString(i + 1));

                    m_GP.Execute(selectbyattriTool, null);
                    m_GP.Execute(aggregateTool, null);

                    IFeatureClass feacls_agg = m_GP.Open(aggregateTool.out_feature_class) as IFeatureClass;
                    setFeatureClassFieldValue(feacls_agg, "Grade", i + 1);

                }
            }
            catch (System.Exception ex)
            {

            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 多边形合并二
        /// </summary>
        /// <param name="dirpath"></param>
        /// <param name="filename"></param>
        /// <param name="socreInterval"></param>
        /// <param name="distance"></param>
        public void AggreationProcessing2(string dirpath, string filename, string filed, int[] socreInterval, int distance)
        {
            //1.Make a layer form the origin featureclass ;
            MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();
            makefeaturelayer.in_features = m_Dirpath + m_Filename + ".shp";
            makefeaturelayer.out_layer = "origin_lyr";
            m_GP.Execute(makefeaturelayer, null);

            #region Dissovle and Aggregation
            for (int i = 0; i < socreInterval.Length - 1; i++)
            {
                //2.Select the feature in the interval, lik score in [low,high)
                SelectLayerByAttribute selectbyattri = new SelectLayerByAttribute();
                selectbyattri.in_layer_or_view = "origin_lyr";
                int scorenode_low = socreInterval[i];
                int scorenode_high = socreInterval[i + 1];
                selectbyattri.selection_type = "NEW_SELECTION";
                string clause = "";
                if (i == socreInterval.Length - 2)
                    clause = filed + " >= " + scorenode_low.ToString() + " AND " + filed + " <= " + scorenode_high.ToString();
                else
                    clause = filed + " >= " + scorenode_low.ToString() + " AND " + filed + " < " + scorenode_high.ToString();
                selectbyattri.where_clause = clause;
                m_GP.Execute(selectbyattri, null);

                //3.Dissolve first
                m_GP.SetEnvironmentValue("workspace", m_OutputTemp_Dissolve);
                string dissolepath = "dissolve" + i.ToString();
                Dissolve dissolvetool = new Dissolve();
                dissolvetool.in_features = "origin_lyr";
                dissolvetool.out_feature_class = dissolepath;
                dissolvetool.multi_part = "SINGLE_PART";
                m_GP.Execute(dissolvetool, null);
                    //set Id value
                IFeatureClass feacls_dissolve = m_GP.Open(dissolvetool.out_feature_class) as IFeatureClass;
                setFeatureClassFieldValue(feacls_dissolve, "Id",i+1);

                //3. aggregating for the selected features and save it in aggregation folder
                string outname = "aggregation" + i.ToString();
                m_GP.SetEnvironmentValue("workspace", m_OutputTemp_Aggregation);
                AggregatePolygons aggregateTool = new AggregatePolygons();
                aggregateTool.in_features = dissolvetool.out_feature_class;
                aggregateTool.aggregation_distance = distance;
                aggregateTool.out_feature_class = outname;
                m_GP.Execute(aggregateTool, null);
                    //set Id Value
                IFeatureClass feacls_agg = m_GP.Open(aggregateTool.out_feature_class) as IFeatureClass;
                setFeatureClassFieldValue(feacls_agg, "Id", i + 1);

            }
            #endregion

            #region Append all layers
            // 4. Compositing all the shapfiles into one file
            //    Use Append tool

            appendFeatureClasses(m_OutputTemp_Dissolve, "result_dissolve");

            appendFeatureClasses(m_OutputTemp_Aggregation, "result_aggregation");
            #endregion
        }
        /// <summary>
        /// 3.根据级别提取到不同要素类(m_MiddleWorkspace)
        /// 进行初步合并,合并距离由区域道路宽度确定
        /// </summary>
        private void ExtractAggregate(double[] gradeNodes, double distThreld)
        {
            MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();
            makefeaturelayer.in_features = m_FeaCls;
            makefeaturelayer.out_layer = "origin_lyr";
            m_GP.Execute(makefeaturelayer, null);

            //1.Select the feature in the interval, lik score in [low,high)
            SelectLayerByAttribute selectbyattriTool = new SelectLayerByAttribute();
            selectbyattriTool.in_layer_or_view = "origin_lyr";
            selectbyattriTool.selection_type = "NEW_SELECTION";

            //2.Aggregating for the selected features and save it in aggregation folder
            AggregatePolygons aggregateTool = new AggregatePolygons();
            aggregateTool.in_features = "origin_lyr";
            aggregateTool.aggregation_distance = distThreld;
            aggregateTool.orthogonality_option = "ORTHOGONAL";

            try
            {
                for (int i = 0; i < gradeNodes.Length - 1; i++)
                {
                    double scorenode_low = gradeNodes[i];
                    double scorenode_high = gradeNodes[i + 1];
                    string clause = "";
                    if (i == gradeNodes.Length - 2)
                        clause = m_PartitionField + " >= " + scorenode_low.ToString() + " AND " + m_PartitionField + " <= " + scorenode_high.ToString();
                    else
                        clause = m_PartitionField + " >= " + scorenode_low.ToString() + " AND " + m_PartitionField + " < " + scorenode_high.ToString();
                    selectbyattriTool.where_clause = clause;

                    string outname = "aggregation" + i.ToString();
                    aggregateTool.out_feature_class = outname;

                    m_GP.Execute(selectbyattriTool, null);
                    m_GP.Execute(aggregateTool, null);

                    IFeatureClass feacls_agg = m_GP.Open(aggregateTool.out_feature_class) as IFeatureClass;
                    setFeatureClassFieldValue(feacls_agg, "Grade", i + 1);

                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Exception in ExtractAggregate!");
            }
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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";
        }