コード例 #1
2
        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
        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);
        }
コード例 #3
0
        public static void select_by_loc(Geoprocessor gp, string in_layer, string select_layer, string method)
        {
            SelectLayerByLocation select_by = new SelectLayerByLocation();

            select_by.in_layer        = in_layer;
            select_by.select_features = select_layer;
            select_by.overlap_type    = method;
            gp.Execute(select_by, null);
        }
コード例 #4
0
        private void SelectOneLayer(string queriedLayer)
        {
            txtMessages.Text += "选择的层: " + queriedLayer + "\r\n";
            txtMessages.Text += "\r\n开始查询. 请稍候...\r\n";
            txtMessages.Update();
            //ScrollToBottom();

            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            txtMessages.Text  += "选择...\r\n";
            txtMessages.Update();
            object dt = "";

            SelectLayerByLocation select = new SelectLayerByLocation();

            if (GetFeatureLayer(queriedLayer) == null)
            {
                return;
            }
            select.in_layer = GetFeatureLayer(queriedLayer);
            if (strSpatialRelationship == "")
            {
                strSpatialRelationship = "INTERSECT";
            }
            select.overlap_type = strSpatialRelationship;
            if (Information.IsNumeric(txtDistance.Text))
            {
                select.search_distance = Convert.ToDouble(txtDistance.Text);
            }
            select.select_features = queryFeatureClass;
            select.selection_type  = "NEW_SELECTION";

            try
            {
                IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(select, null);
                if (results != null)
                {
                    if (results.Status != esriJobStatus.esriJobSucceeded)
                    {
                        txtMessages.Text += "选择要素/层失败: " + queriedLayer + "\r\n";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("空间位置空间关系查询问题: " + ex.Message);
            }

            txtMessages.Text += ReturnMessages(gp);

            txtMessages.Text += "\r\n完成.\r\n";
            txtMessages.Text += "--------------------------------\r\n";
            ScrollToBottom(txtMessages);
            txtMessages.Update();
        }