2

I have geocoded some locations but I need to remove the unmatched locations that are in the resulting FeatureClass. How can I do this programmatically with C#? I am able to get the unmatched features but I can't seem to figure out how to actually remove them from the FeatureClass.

public static void RemoveUnmatchedFeatureFromFeatureClass(string workSpace, string featureClass)
    {
        IWorkspaceFactory workspaceFactory = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory")) as IWorkspaceFactory;
        IFeatureWorkspace featureWorkspace = workspaceFactory.OpenFromFile(workSpace, 0) as IFeatureWorkspace;
        IFeatureClass unMatchedFeatureClass = featureWorkspace.OpenFeatureClass(featureClass);

        IQueryFilter queryFilter = new QueryFilterClass();
        queryFilter.WhereClause = "Status = 'U'";
        using (ComReleaser comReleaser = new ComReleaser())
        {
            IFeatureCursor newCursor = unMatchedFeatureClass.Search(queryFilter, false);
            IFeature unmatchedfeature = newCursor.NextFeature();

            while (unmatchedfeature != null)
            {
                //Remove feature

                unmatchedfeature = newCursor.NextFeature();
            }
        }
    }

1 Answer 1

2

The most efficient way to delete a bunch of rows that fulfill a query, in your case where Status = 'U' is to call the DeleteSearchedRows method on ITable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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