Extract Spatial ID from a Polygon

799
2
04-20-2021 11:30 AM
rajujee
New Contributor II

Hi,

I am new to ArcObjects, I am spinning my wheels extracting Spatial ID from a polygon. I have a features with 100 blocks when I add a point features on polygon feature. I need its ID. 

Any help or link is appreciated.

R

0 Kudos
2 Replies
BrentHoskisson
Occasional Contributor III

You need to spend more time constructing your question so it will be understood.  It appears you are trying to to search polygons with a point feature.  If this is so you want to start by creating a spatial filter

Here is a sample that is set up to intersect:

 public static ISpatialFilter CreateSpatialFilter(IFeatureClass fc, IGeometry shape)
        {
            if (fc == null) return null;
            ISpatialFilter sf = new SpatialFilterClass();
            sf.GeometryField = fc.ShapeFieldName;
            sf.Geometry = shape; 
            sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            return sf;
        }

 

Then you can use this directly on your feature class using the Search function..

IFeatureCursor fcursor = fc.Search(CreateSpatialFilter(fc, shape), true);

 

Now index through the cursor to get the polygon id's.

 

Good Luck

Brent Hoskisson

rajujee
New Contributor II

This worked as a charm. Thanks Brent.

0 Kudos