ISpatialFilter Interface

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

Description

ISpatialFilter is a QueryFilter that includes both spatial and attribute constraints. Therefore, a SpatialFilter can be used to restrict the set of features retrieved from a feature class using both spatial and attribute restrictions. 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 IQueryFilterinterface for help on the inherited methods and properties.

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.

The Geometry 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 can optionally be populated with a string to define spatial relationships that are not possible using the esriSpatialRelEnum values. In this case the SpatialRel parameter must be set to esriSpatialRelRelation. See the help on the SpatialRelDescription property for details on string formatting.

The esriGeometry library 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.

Members

Name Description
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., TT*FFT***' 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.

ISpatialFilter.FilterOwnsGeometry Property

Indicates whether the filter owns the query geometry.

Public ReadOnly Property FilterOwnsGeometry As Boolean
public bool FilterOwnsGeometry {get;}

ISpatialFilter.Geometry Property

The query geometry used to filter results.

Public Property Geometry As IGeometry
public IGeometry Geometry {get; set;}

Description

Only high-level geometries, envelopes and geometry bags can be used. High-level geometries are polygons, polylines, points, and multipoints. Low-level geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used.

Remarks

If a geometry bag is being used as the filter's query geometry, a spatial index should be created for the bag prior to any evaluation using the filter. This can be done by casting the geometry bag to the ISpatialIndex interface, setting the AllowIndexing property to true, and calling the Invalidate method.

Note that at ArcGIS 9.3 and later, setting this property to null will cause an error.

ISpatialFilter.GeometryEx Property

The query geometry used to filter results.

Public Sub set_GeometryEx ( _
    ByVal Geometry As IGeometry, _
    ByVal A_2 As Boolean _
)
public void set_GeometryEx (
    IGeometry Geometry,
    bool A_2
);

ISpatialFilter.GeometryField Property

The name of the Geometry field to which the filter applies.

Public Property GeometryField As String
public string GeometryField {get; set;}

ISpatialFilter.SearchOrder Property

The search order used by the filter.

Public Property SearchOrder As esriSearchOrder
public esriSearchOrder SearchOrder {get; set;}

Description

SearchOrder gets the order in which spatial searches are applied by the RDBMS (ArcSDE). This property only affects ArcSDE Geodatabase data. It has no effect on Personal or File Geodatabase, Coverage or Shapefile data.

Remarks

SearchOrdergets the order in which spatial searches are applied by the RDBMS (ArcSDE). The spatial component of the search should generally be applied before the attribute component. The more spatially restrictive of the two should be used. In the following query, "Find all wells with particulate counts between 1000 and 1200 in within 5 miles of a school", the esriSearchOrderAttribute enumerator is more effective. If the filter geometry is the outline of the city of Modesto, California and the attribute query is "street_name = 'Main St.'" then esriSearchOrderSpatial should be used, as there are a large number of "Main St." records at a national level.Please note that esriSearchOrderSpatial is the default option. The following esriSearchOrder enumeration values are used to set the search order:esriSearchOrderAttributeSets the search order to attribute first.esriSearchOrderSpatialSets the search order to spatial first.

ISpatialFilter.SpatialRel Property

The spatial relationship checked by the filter.

Public Property SpatialRel As esriSpatialRelEnum
public esriSpatialRelEnum SpatialRel {get; set;}

Description

Tolerances

Most spatial relationships are defined by the intersection of boundaries, interior and exterior. All shapes have an interior. Lines and polygons have a boundary. Most spatial relations use a tolerance when examining the spatial relationship between two features. In most cases this tolerance is the XY tolerance of the search feature. All geometries within the tolerance are seen as intersecting. In the overlaps case the tolerance sets the minimum overlap. Geometries that overlap less than the tolerance will not be seen as overlapping.

Tolerance

Relationships that use the XY tolerance:

esriSpatialRelIntersectsesriSpatialRelEnvelopeIntersectsesriSpatialRelTouchesesriSpatialRelOverlapsesriSpatialRelCrossesesriSpatialRelWithinesriSpatialRelContains

The esriSpatialRelRelation uses the XY resolution. Usually ten times smaller than the XY tolerance.

esriSpatialRelIndexIntersects does not use a tolerance.

ISpatialFilter.SpatialRelDescription Property

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., TT*FFT***' represents CONTAIN.

Public Property SpatialRelDescription As String
public string SpatialRelDescription {get; set;}

Description

A nine character string containing describing the spatial relationships to be tested by the spatial filter. Required when setting the SpatialRel property to use the esriSpatialRelRelation enumerator.

Remarks

The SpatialRelDescription allows the comparison of any spatial relationship between two geometries. A spatial relationship is defined by the intersections between the boundary, interior, and exterior of the query geometry and the requested geometry.

All of the spatial relationships defined by the esriSpatialRelEnum enumeration can be duplicated using this property.

Interior:The interior of a shape is defined as the entire shape minus its boundary. All shapes have interior.Boundary:Linear and area shapes have boundaries, but point shapes do not. The boundary of linear shapes consists of the end points of all linear parts. The boundary of area shapes consists of the linear boundary of the polygon shell(s).Exterior:The area outside a shape. All shapes have an exterior.

Each element for the first shape, the query geometry, may be tested against each element of the second shape, the requested geometry, giving nine possible spatial intersections as listed in the table below:

Query Geometry Requested Geometry
1 interior interior
2 interior boundary
3 interior exterior
4 boundary interior
5 boundary boundary
6 boundary exterior
7 exterior interior
8 exterior boundary
9 exterior exterior

The nine-characters string expected by ISpatialFilter::SpatialRelDescription, is used to specify whether the intersection of each of the elements in the array is true (T), false (F), or not tested (*).

For instance, in 'FFFTTT***', relationships 1-3 must be false, relationships 4-6 must be true, and relationships 7-9 are not tested.Note that any two shapes' exteriors always intersect.

Example Strings

Shares a boundary: '****T***'Shares a boundary and interiors intersect: 'T***T****'Shares a boundary and interiors do not intersect: 'F***T****'Does not touch the boundary and interiors intersect: 'T***F****'

Approximate esriSpatialRelEnum SpatialRelDescription Strings

Relation Query Geometry Requested Geometry String
Contains Line Line TT*FFT***
Contains Point Line TT*FFT***
Contains Point Point T********
Contains Line Poly TT*FFT***
Contains Poly Poly TT*FFT***
Crosses Line Line TF*FF****
Crosses Poly Line TT**F****
Crosses Line Poly TT**T****
Overlaps Line Line TT*T*****
Overlaps Point Point T********
Overlaps Poly Poly TT*T*****
Touch Line Line FF*FT****
Touch Poly Line FF*FT****
Touch Line Poly FF*FT****
Touch Poly Poly FF*FT****
Within Line Line TF**F****
Within Point Line T********
Within Point Point T********
Within Line Poly TF**F****
Within Poly Poly TF**F****

Inherited Interfaces

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

Classes that implement ISpatialFilter

Classes Description
ImageQueryFilter (esriCarto) An image query filter.
SpatialFilter Esri Spatial Filter object.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.