0

I am using the Identity tool which takes 3 parameters: in_features, identity_features, and out_features. Does the output FeatureClass need to have fields that are a combination of the fields in in_features and identity_features?

I keep getting an error when I the out_features only contains the fields in in_features and not both in_features and identity_features.

public static void PerformIdentityOverlay(string workSpace, string inputFeatureClassName, string identityFeatureClassName, string outputFeatureClassName)
{
     IWorkspaceFactory workspaceFactory = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory")) as IWorkspaceFactory;
     IFeatureWorkspace featureWorkspace = workspaceFactory.OpenFromFile(workSpace, 0) as IFeatureWorkspace;
     IFeatureWorkspaceManage featureWorkspaceManage = featureWorkspace as IFeatureWorkspaceManage;

     IWorkspace workspace = workspaceFactory.OpenFromFile(workSpace, 0);

     IFeatureClass identityFeatureClass = featureWorkspace.OpenFeatureClass(identityFeatureClassName);

     IFeatureClass inputFeatureClass = featureWorkspace.OpenFeatureClass(inputFeatureClassName);
     IFields inputFieldsFromFeatureClass = inputFeatureClass.Fields;
     String shapeFieldName = inputFeatureClass.ShapeFieldName;



     IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
     IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;

     // Use IFieldChecker to create a validated fields collection.
     IFieldChecker fieldChecker = new FieldCheckerClass();
     IEnumFieldError enumFieldError = null;
     IFields validatedFields = null;
     fieldChecker.ValidateWorkspace = workspace;
     fieldChecker.Validate(inputFieldsFromFeatureClass, out enumFieldError, out
                                    validatedFields);

     IFeatureClass outputFeatureClass = featureWorkspace.CreateFeatureClass(outputFeatureClassName, inputFieldsFromFeatureClass, ocDesc.InstanceCLSID,
                                                ocDesc.ClassExtensionCLSID, esriFeatureType.esriFTSimple, shapeFieldName, "");

     Geoprocessor gProc = new Geoprocessor();
     Identity ident = new Identity(inputFeatureClass, identityFeatureClass, outputFeatureClass);
     IGeoProcessorResult result = gProc.Execute(ident, null) as
                IGeoProcessorResult;
}
1

So it turns out that to use an Identity Tool you need to pass it the string of the location for the FeatureClass. This was somewhat confusing as the parameters state that it must be an Object.

Identity ident = new Identity();
        ident.in_features = inputFeatureClassLocation;//String
        ident.identity_features = identityFeatureClassLocation;//String
        ident.out_feature_class = outputFeatureClassLocation;//String
  • 1
    Right, the tool is going to create the output object for you. The docs are like that sometimes, they say object when they really should say the name of a new object. – Jersey Andy Apr 1 '16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.