When the input to the following method is a feature class on disk the geoprocessor gives the expected results. However, when I pass in a feature class that is created via arcobjects to an in_memory workspace then I get either a result with no features or only a few of the clipped features. The clip_features input has only one polygon and it is in the same spatial reference as the in_features to be clipped.
private void ClipFeatures(string fileNameAndPath, ref IFeatureClass inMemPolyFc)
{
Geoprocessor gp = new Geoprocessor();
Clip clip = new Clip();
clip.clip_features = inMemPolyFc;
clip.in_features = fileNameAndPath;
clip.out_feature_class = @"in_memory\clippedFile";
gp.OverwriteOutput = true;
gp.AddOutputsToMap = true;
try
{
gp.Execute(clip, null);
}
catch (Exception)
{
string gpError = getGPMessages(gp);
MessageBox.Show(@"A geoprocessing error occurred: " + Environment.NewLine + Environment.NewLine + gpError,
clsPropSet.AppName);
}
}
The gp executes sucessfully with the in_memory fc but the results are wrong. After creating the in_memory fc via arcobjects I added it the map during debugging and it appears correctly in the map document. Is this a bug in the gp tool?