Is it possible to spatially pre-clip layers (say with a IPolygon object) before they are loaded into ArcMap?

This would be a bit like a query definition but spatial and for raster data.


2 Answers 2


There is an ArcMap DataFrame tab that allows you to Clip layers to a Shape. This doesn't alter the data on disk, only the layer view is clipped. You can also exclude specific layers from being clipped in your mxd.


Create a query filter Query filters allow you to use attribute data to create a subset of your original data. They are used for many different tasks in ArcObjects, such as selecting features in a layer or creating a subset of the features and performing an operation on those features alone. It is important to note that a spatial filter implements IQueryFilter so you can use a query filter in a spatial query as well. When creating a query based upon a string attribute be sure to enclose your string condition in single quotes (e.g. "name='ESRI'")

QueryFilter queryFilter = new QueryFilter();queryFilter.setWhereClause("Attribute=value");

Select features from a layer based upon attributes Once you have a query filter you can use it to select features in a layer. The second parameter of the selectFeatures method allows you to determine what type of selection to perform, such as create a new selection set, append the selection to the current selection set, and several others.

layer.selectFeatures(queryfilter,esriSelectionResultEnum.esriSelectionResultNew,false);int numberOfSelectedFeatures = map.getSelectionCount();

Perform a spatial query on a map A spatial filter, which also implements IQueryFilter, searches a feature class for all the features which satisfy the spatial relation with an IGeometry. There are many objects which implement IGeometry, such as Point, MultiPoint, Line, and so on. The list of spatial relations can be found in esriSpatialRelEnum.

SpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.setGeometryByRef(searchGeometry);String shapeFieldString = featureClass.getShapeFieldName();spatialFilter.setGeometryField(shapeFieldString);spatialFilter.setSpatialRel(spatialRelation); if ((whereClause == null )){ spatialFilter.setWhereClause("");} else { spatialFilter.setWhereClause(whereClause);}

featureCursor = featureClass.search(spatialFilter,false);

9.2 Help EDN quickstart page


  • Yes, I have seen this, but I think you would have to create a new FC from the resulting featureCursor. What I really want to do is limit the features spatially just before ILayer gets added to the TOC in ArcMap.
    – Vidar
    May 11, 2012 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.