Hi I had a task to get the area of the feature polygon within a boundarySo I got the envelope of the boundary and did a spatial query to get the features inside that Boundarybut 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 envelopemy code goes like thisIMxDocument 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 itAm i missing something here?Please guide..