Select to view content in your preferred language

Need efficient means to find overlapping features ObjectID's

742
2
02-28-2011 07:27 AM
ESRICustomer
Occasional Contributor
My environment...
[INDENT]ArcObjects 9.3.X[/INDENT]
[INDENT]Visual Studio 2008[/INDENT]
[INDENT]VB.NET[/INDENT]


Please refer to the attached image to follow along with my question.

I've been looking at the IRelationalOperator and ITopologicalOperator and these do not seem to provide the means to do what I'm after with the efficiency I was hoping for.

Given a particular feature (ParcelXYZ), it would seem reasonable to me to be able to take that parcel and get a very direct and quick determination of the overlapping polygons from the wetlands area layer (shown in yellow).

From what I can determine, it appears the only way to do this is to iterate over every single feature in the wetlands area layer (shown in yellow), asking each feature if it overlaps ParcelXYZ.

To me, the quicker and more efficient means that I'm hoping exists would be the exact opposite of that process.

Ideally, you would start with ParcelXYZ, and then simply ask "give me all the feature ObjectID's from the wetlands layer (shown in yellow) that overlap this particular parcel"

Perhaps internally, this hypothetical ESRI method would restrict the searched area to the parcel's shape, and then is able to quickly determine what features overlap it without having to iterate the entire set of features in the wetlands area layer (shown in yellow)

Imagine a method something like this...
[INDENT]OverlappingFeaturesObjectIDs = ParcelXYZ.OverlappingFeatures(Wetlands)[/INDENT]

Is there a way to do this similarly to what I describe here, or am I stuck with iterating over every feature in the wetlands area?

Feb 28 2011 10:05 A.M. PST
[INDENT]After some more searching it seems that the ISpatialFilter interface holds some promise.
I can restrict the features being examined to those that share a spatial relationship with my parcel polygon.[/INDENT]
0 Kudos
2 Replies
JamesCrandall
MVP Alum
I think you want to implement ISpatialFilter and set the .SpatialRel to esriSpatialRelIntersects

http://resources.esri.com/help/9.3/arcgisserver/apis/arcobjects/esrigeodatabase/ispatialfilter.htm
0 Kudos
ESRICustomer
Occasional Contributor
I think you want to implement ISpatialFilter and set the .SpatialRel to esriSpatialRelIntersects

http://resources.esri.com/help/9.3/arcgisserver/apis/arcobjects/esrigeodatabase/ispatialfilter.htm



You're correct.  I tried it, it's awesome.  Here's the meat of the code i used...

 

        Dim parcelFeat_ As IFeature = Nothing
        parcelFeat_ = ParcelLayer.esriIFeatureLayer.FeatureClass.GetFeature(239319)

        Dim spatialFilter_ As ISpatialFilter = New SpatialFilter
        With spatialFilter_
            .SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps
            .GeometryField = "SHAPE"
            .Geometry = parcelFeat_.Shape
        End With

        Dim wetOverlapFeat_ As IFeature = Nothing
        Dim wetOverlappingFeatsCursor_ As IFeatureCursor = wetLandsFeatureClass.Search(spatialFilter_, False)

        wetOverlapFeat_ = wetOverlappingFeatsCursor_.NextFeature
        Do Until wetOverlapFeat_ Is Nothing
            Debug.Print("Overlapping Feature Found: {0}", wetOverlapFeat_.OID)
            wetOverlapFeat_ = wetOverlappingFeatsCursor_.NextFeature
        Loop
0 Kudos