Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to spatially pre-clip layers (say with a IPolygon object) before they are loaded into ArcMap - a bit like a query definition but spatial?? Also I need to do this for raster data?


share|improve this question
What were you planning on doing this pre-clip with? A good spatial database could do it for you for vectors, don't know about rasters however. – GIS-Jonathan May 11 '12 at 9:19
Just load it into ArcMap as normal. Basically I know you can do a Layer Definition on a layer then load into ArcMap but that only works with attributes, not the spatial column - I was just wondering if I may have missed anything, and it was in fact possible to do a spatial definition query. This would definitley need to be done with rasters too. – Vidar May 11 '12 at 11:22
with shapefiles you can do it with no problem, if you have the column with the xlong and another with y/lat. all you need to do is delete the points that fall outside your area directly in the ".dbf". Since you have the polygons, you can do something similar. How do you plan to do this ? with arcpy ? – A.R May 11 '12 at 14:15
up vote 7 down vote accepted

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.

share|improve this answer
Really! That could work! – Vidar May 11 '12 at 14:51
Keep in mind - it only affects visibility. I believe it will not increase performance of further queries. – Alex Markov May 11 '12 at 15:51
I really think this is best thing I've learned all year! – Jay Cummins May 11 '12 at 15:51
I am so happy to have found this out - it's just the ticket!!! – Vidar May 11 '12 at 16:32
This doesn't filter rows in Attribute table rather hide the visibility of features – Farid Cher Jul 4 '15 at 21:46

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 =,false);

9.2 Help EDN quickstart page


share|improve this answer
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 '12 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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