Using the Intersect Geoprocessor with IFeatureLayers in C#

Discussion created by wadedrane on Apr 12, 2010
Latest reply on Apr 15, 2010 by michaeltischler
I am trying to get the following code to work but am having no luck. I am developing in C# using the geoprocessor. I want to intersect two featurelayers within the ArcMap TOC but I can not find an example to do this. The only example is code that uses pathnames to geodatabases for the multiple inputs and that doesnt show me how to use the featurelayers in the TOC of ArcMap for the inputs. This is the code I have but it seems that the intersect doesnt like the featurelayer names I am using for the input. Any help is appreciated. Thanks

The Code:

using ESRI.ArcGIS.Geoprocessor;

// LOJIC.ArcGIS.Carto.Layers.GetFeatureLayerByName is a function to get the featurelayer
IFeatureLayer pParcelFLayer = LOJIC.ArcGIS.Carto.Layers.GetFeatureLayerByName(farmassessment.m_mxDocument.ActiveView, "Parcel Lines");
IFeatureLayer pSoilsFLayer = LOJIC.ArcGIS.Carto.Layers.GetFeatureLayerByName(farmassessment.m_mxDocument.ActiveView, "Soils");
// String for the output path
String stroutput = "J:\\pva\\Appdata\\Farm\\fa" + strParcelID;
//Setting up the Geoprocessor
Geoprocessor GP = new Geoprocessor();
GP.OverwriteOutput = true;
Intersect intersectLayers = new Intersect();
intersectLayers.in_features = "'" + pParcelFLayer.Name + "' '';'" + pSoilsFLayer.Name + "' ''";
intersectLayers.out_feature_class = stroutput;
intersectLayers.join_attributes = "ALL";
intersectLayers.output_type = "INPUT";
GP.Execute(intersectLayers, null);