Howdy All, I've progressed down my problems path to my next challenge... I have two feature layers that both have multiple features selected in them... One is street centerlines (polylines) and the other is a polygon layer, some of which intersect/cover the street centerline layer... I need to remove from the polygon selection those polygons that DO intersect/cover the street centerlines. There are multiple polygons in the original selection not all of which intersect the streets, and there are multiple street centerlines in the street centerline original selection. I need a programmatic solution to this, I can manually perform what I need by using the "Select by Location" tool and in there specify "remove from the currently selected features in" selection method... OK That's great, but I need to automate this via code... I think i need to use a Spatial Filter and use the "SelectFeatures" method in the polygon layer's Selection object... I just can't figure out how to setup the spatial filter to do this... My stumbling block is getting the multiple line geometries into the ONE geometry of the Spatial filter... And had to specify to subtract the features from the selection... maybe I'm going down the wrong path here... If so, please enlighten me as to the best path to travel!!! 🙂
I'm pretty sure this is an easy one, but I'm just having one of those days where my brain just isn't firing on all cylinders!
You set up the Spatial Filter object so that it will select the features that you want to remove. You pass this Spatial Filter into IFeatureSelection::SelectFeatures(). You also set the Combination Method parameter to Subtract.
Yes. You set the spatial filter's geometry to whatever geometry will select the features you want. If you want to select features on one layer using the geometries of multiple features from another layer then you need to create a geometry that is the union of those feature geometries. This can be done using ITopologicalOperator. The most efficient method would be to use the ConstructUnion method, which requires an IEnumGeometry object. You can get this from IEnumGeometryBind.