ArcGIS Developer Help  (GeoDatabase)    

ISpatialFilter Interface

Provides access to members that return and modify the type of spatial relationship that the filter will use.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


ISpatialFilter filters data based on a spatial relationship.

The most common ways to perform a spatial query using a spatial filter is to create the spatial filter using this interface and use it as a parameter for IFeatureClass::Search, IFeatureClass::Select or similar methods on feature layers, selection sets, etc.

ISpatialFilter inherits from IQueryFilter so you can optionally specify a string defining a where clause, include a list of columns to be retrieved or specify the spatial reference in which to output the geometry of the resulting features. See the IQueryFilter interface for help on the inherited methods and properties.

The Geometry, GeometryField and SpatialRel properties are required.

Geometry is the source geometry in relation to which the spatial selection will be performed. GeometryField is a string corresponding to the name of the field containing the geometries to be compared to the source geometry. Finally the spatial relationship is specified with the SpatialRel property passing it an esriSpatialRelEnum .

A SearchOrder can be specified using an esriSearchOrder. When an attribute query is specified it will specify which of the attritute or spatial part of the query is executed first. A judicious choice may significantly improve the performances. This is only available with SDE datasources.

The SpatialRelDescription is a string containing specific codes that can be used instead of the SpatialRel property to define extra spatial relationships. In this case the SpatialRel parameter must be set to esriSpatialRelRelation. See the help on the SpatialRelDescription topic for detail on the strings to use.

The esriGeometry provides other ways to perform a spatial selection. See for instance  the example associated with ITopologicalOperator that performs a spatial selection on polylines that share a line segment.


Method AddField Appends a single field name to the list of sub-fields.
Read-only property FilterOwnsGeometry Indicates whether the filter owns the query geometry.
Read/write property Geometry The query geometry used to filter results.
Write-only property GeometryEx The query geometry used to filter results.
Read/write property GeometryField The name of the Geometry field to which the filter applies.
Read/write property OutputSpatialReference The spatial reference in which to output geometry for a given field.
Read/write property SearchOrder The search order used by the filter.
Read/write property SpatialRel The spatial relationship checked by the filter.
Read/write property SpatialRelDescription The array elements which describe the spatial relation between the query geometry and the requested geometries. There are 9 chars in this string which can be either 'F', 'T' or '*'; e.g., FF*TTT***' represents CONTAIN.
Read/write property SubFields The comma delimited list of field names for the filter.
Read/write property WhereClause The where clause for the filter.

Inherited Interfaces

Interfaces Description
IQueryFilter Provides access to members that filter data based on attribute values and or relationships.

CoClasses that implement ISpatialFilter

CoClasses and Classes Description
SpatialFilter ESRI Spatial Filter Object.
TemporalQueryFilter (esriTrackingAnalyst) Controls properties for the temporal query filter.
[Visual Basic 6.0]

The following code excerpt shows how to get a reference to an ISpatialFilter interface, set the necessary values and execute the search.

NOTE: All three of the ISpatialFilter methods Geometry, GeometryField and SpatialEnum are required.

Create a point to use for the search:

  Dim pPoint As IPoint
  Set pPoint = New esriGeometry.Point
  pPoint.PutCoords -117.946, 35.823

Getting a reference:

  Dim pFilter As IspatialFilter 
  Set pFilter = New SpatialFilter 

Setting the Geometry, GeometryField and SpatialRel parameters:

  With pFilter 
    Set .Geometry = pPoint 
    .GeometryField = "SHAPE" 
    .SpatialRel = esriSpatialRelIntersects 
  End With 

Execute the filter:

  Dim pFeatureCursor As IfeatureCursor 
  Set pFeatureCursor = pFeatureClass.Search(pFilter, False) 

Note on ORDER BY and returning sorted data: ORDER BY cannot be used with ArcObjects. If ordered results are required you need to use ITableSort. A method that allows the use of ORDER BY is planned for a future release.

See Also

IQueryDef Interface | IQueryFilter Interface | IQueryDef Interface | IFeatureClass.Search Method | IQueryFilter Interface | IFeatureClass.GetFeatures Method | IFeatureClass.FeatureCount Method | IQueryFilter Interface


Feedback Send feedback on this page