santoshf2

spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin; not working

Discussion created by santoshf2 on Mar 28, 2012
Latest reply on Mar 30, 2012 by santoshf2
Hi
I had a task to get the area of the feature polygon within a boundary
So I got the envelope of the boundary and did a spatial query to get the features inside that Boundary

but my problem is I am able to get the elements that overlaps the envelope but not exactly inside it.. the polygon is not clipping to the envelope
my code goes like this
IMxDocument mxDoc = (IMxDocument)GetMxDocumentFromArcMap(m_application);
            IEnvelope gridEnvelope = GetGridExtents("Z29");
            IFeatureClass featureClass = GetFeatureClassFromShapefileOnDisk("D:\\Projects\\Working\\BMRDA\\data", "Hoskote_Satellite_Polygon");

            // Create the spatial filter and set its spatial constraints.
            ISpatialFilter spatialFilter = new SpatialFilterClass();
            spatialFilter.Geometry = gridEnvelope.Envelope;
            spatialFilter.GeometryField = featureClass.ShapeFieldName;
            spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;
            spatialFilter.set_OutputSpatialReference(featureClass.ShapeFieldName, mxDoc.FocusMap.SpatialReference);

            // Set the attribute constraints and subfields.
            // We want to exclude ramps, highways and interstates.
            spatialFilter.WhereClause = "LEVEL3 = 'AGRICULTURE LAND'";

            // Execute the query.
            IFeatureCursor featureCursor = featureClass.Search(spatialFilter, true);
            ESRI.ArcGIS.Geodatabase.IFeature feature;  // Automatically initialized to null. Used to test existence of a feature in the featureCursor
            double dbArea = 0.0;
            int intCount = 0;
            while ((feature = featureCursor.NextFeature()) != null)
            {
                IArea area = (IArea)feature.Shape;
                dbArea = dbArea + area.Area;
                intCount++;
            }

the spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin; does not work it returns me null I want the polygon to be clipped and get the area of it
Am i missing something here?
Please guide..

Outcomes