Unfortunately did not work, only creates an empty layer.Simple exampel: IFeatureLayer featlayerP = Class2.FindFeatureLayer("monitoring.dbo.path_polygon", mxDocument); IFeatureLayer featlayerC = Class2.FindFeatureLayer("monitoring.dbo.%compartment_polygon", mxDocument); Geoprocessor GP = new Geoprocessor(); // Intialize the MakeFeatureLayer tool MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer(); makefeaturelayer.in_features = featlayerP; makefeaturelayer.out_layer = "Wells_Lyr"; copyfeatures.RunTool(GP, makefeaturelayer, null); makefeaturelayer.in_features = featlayerC; makefeaturelayer.out_layer = "bedrock_Lyr"; copyfeatures.RunTool(GP, makefeaturelayer, null); SelectLayerByLocation SelectByLocation = new SelectLayerByLocation(); SelectByLocation.in_layer = "Wells_Lyr"; SelectByLocation.select_features = "bedrock_Lyr"; SelectByLocation.overlap_type = "INTERSECT"; copyfeatures.RunTool(GP, SelectByLocation, null); SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute(); SelectByAttribute.in_layer_or_view = "Wells_Lyr"; SelectByAttribute.selection_type = "NEW_SELECTION"; SelectByAttribute.where_clause = "id = '916EEBA8-7721-4BD3-8833-B61AC78A8F74'"; copyfeatures.RunTool(GP, SelectByAttribute, null); // Intialize the CopyFeatures tool CopyFeatures CopyFeatures = new CopyFeatures(); CopyFeatures.in_features = "Wells_Lyr";// "monitoring.dbo.path_polygon"; CopyFeatures.out_feature_class = @C:\Users\kharitonov.sv\Documents\ArcGIS\Default.gdb\Wells_Lyr_c; copyfeatures.RunTool(GP, CopyFeatures, null); I tried it the other way. He gives me all the values ??????of the parent layer. Secret:( IFeatureSelection featureSelection = featlayerP as IFeatureSelection; IQueryFilter qFilter = new QueryFilter(); qFilter.WhereClause = "id = '916EEBA8-7721-4BD3-8833-B61AC78A8F74'"; ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(qFilter, false, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; IFeature feature = featureCursor.NextFeature(); List<IFeature> features = new List<IFeature>(); while (feature != null) { features.Add(feature); feature = featureCursor.NextFeature(); } IFeatureClass r = (IFeatureClass)features[0].Class; IFeatureLayer y = new FeatureLayerClass(); y.FeatureClass = r; y.Name = "new"; mxDocument.Maps.Item[1].AddLayer(y); mxDocument.ActiveView.Refresh();
IFeatureLayer featlayerP = Class2.FindFeatureLayer("monitoring.dbo.path_polygon", mxDocument); IFeatureLayer featlayerC = Class2.FindFeatureLayer("monitoring.dbo.%compartment_polygon", mxDocument); Geoprocessor GP = new Geoprocessor(); // Intialize the MakeFeatureLayer tool MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer(); makefeaturelayer.in_features = featlayerP; makefeaturelayer.out_layer = "Wells_Lyr"; copyfeatures.RunTool(GP, makefeaturelayer, null); makefeaturelayer.in_features = featlayerC; makefeaturelayer.out_layer = "bedrock_Lyr"; copyfeatures.RunTool(GP, makefeaturelayer, null); SelectLayerByLocation SelectByLocation = new SelectLayerByLocation(); SelectByLocation.in_layer = "Wells_Lyr"; SelectByLocation.select_features = "bedrock_Lyr"; SelectByLocation.overlap_type = "INTERSECT"; copyfeatures.RunTool(GP, SelectByLocation, null); SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute(); SelectByAttribute.in_layer_or_view = "Wells_Lyr"; SelectByAttribute.selection_type = "NEW_SELECTION"; SelectByAttribute.where_clause = "id = '916EEBA8-7721-4BD3-8833-B61AC78A8F74'"; copyfeatures.RunTool(GP, SelectByAttribute, null); // Intialize the CopyFeatures tool CopyFeatures CopyFeatures = new CopyFeatures(); CopyFeatures.in_features = "Wells_Lyr";// "monitoring.dbo.path_polygon"; CopyFeatures.out_feature_class = @C:\Users\kharitonov.sv\Documents\ArcGIS\Default.gdb\Wells_Lyr_c; copyfeatures.RunTool(GP, CopyFeatures, null);
IFeatureSelection featureSelection = featlayerP as IFeatureSelection; IQueryFilter qFilter = new QueryFilter(); qFilter.WhereClause = "id = '916EEBA8-7721-4BD3-8833-B61AC78A8F74'"; ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(qFilter, false, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; IFeature feature = featureCursor.NextFeature(); List<IFeature> features = new List<IFeature>(); while (feature != null) { features.Add(feature); feature = featureCursor.NextFeature(); } IFeatureClass r = (IFeatureClass)features[0].Class; IFeatureLayer y = new FeatureLayerClass(); y.FeatureClass = r; y.Name = "new"; mxDocument.Maps.Item[1].AddLayer(y); mxDocument.ActiveView.Refresh();
Good to hear that the solution works but I am sorry Sergey .. I do not have an idea on your second question. I think you can mark this post as Answered, so that i also get a point added 😛 .. and start a new post for your second question. 🙂Regards,Pavan
It worked for me though.. I applied SelectlayerByAttributes on my layer. This is how didIFeatureLayer pFeatureLayer = GetFeatureLayer(); // I got my desired featurelayer from layers list displayed on map. SelectLayerByAttribute pSelect = new SelectLayerByAttribute(); pSelect .in_layer_or_view = pFeatureLayer; // directly take your featurelayerP or featurelayerC pSelect .selection_type = "NEW_SELECTION"; pSelect .where_clause = "id = '916EEBA8-7721-4BD3-8833-B61AC78A8F74'"; // I had given a Where condition .. "Country = India" pSelect.out_layer_or_view = "Filtered_layer"; copyfeatures.RunTool(GP, SelectByAttribute, null); // RunTool () as mentioned in the link // Intialize the CopyFeatures tool CopyFeatures CopyFeatures = new CopyFeatures();// Here since the features are already selected in pFeatureLayer.. CopyFeatures.in_features = pFeatureLayer; // only selected elements are passed as in_features. CopyFeatures.out_feature_class = @C:\Users\kharitonov.sv\Documents\ArcGIS\Default.gdb\Wells_Lyr_c; // specify a valid path that exists copyfeatures.RunTool(GP, CopyFeatures, null); Worked for me this way.. i feel you should also get it.Regards,Pavan
string outs = @Database Connections\Connection to 192.168.56.102 (3).sde; CopyFeatures.in_features = featlayerP; CopyFeatures.out_feature_class = outs+@\\Wells_Lyr_c;
Use CopyFeatures class which you can execute through Geoprocessor ,Check this link for sample example http://edndoc.esri.com/arcobjects/9.2/NET/ViewCodePages/43d8cc77-5193-4ca8-9878-6027782e2bbbexecutetoolcopyfeatures.cs.htmHope this helps,Regards,Pavan
Hi, I have one problem!How to copy an object from the layer selected by the filter, in another new layer.I can get the selected feature, but how to add it to a new layer don't know: (
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.