Spatial Relation Tool

Description:

In this sample you learn how to use a spatial filter and the relation enumerator to select features based on user the existence (or lack of) of intersections between the interior, exterior, and/or boundary of a search graphic and the members of a featureclass. By adjusting the relationships tested, all of the other spatial relation enumerators can be duplicated and other relationships explored.

How to use:
  1. Open the VB project (RelateTool.vbp) and compile the code. Add the RelateTool.dll to ArcMap through the customize panel. A new command category "Developer Samples" will now be listed. Select it and add the "Spatial Matrix" command to the ArcMap Main Menu.
  2. Add the States data from the USA dataset. This can be from any data source (Geodatabase, PersonalGeodatabase, Shapefile, or Coverage). Select a state polygon (Oklahoma is a good choice). Right click on the layer and convert the selected feature to a graphic. Remove the States layer, and add the USA counties layer.
  3. Select the graphic and change the symbology. No fill, with a red outline works well.
  4. Select the state graphic and bring up the Spatial Matrix tool.
  5. Click on the center matrix cell (upper left).

    * * *

    * T *

    * * *

    Filters for all features in the counties feature class whose boundaries intersect. Select "Ok". This will return all of the counties on either side of the state graphic.

  6. Bring up the Spatial Matrix tool and click on the center left (T-True) and the center (T - True) cells.

    * * *

    T T *

    * * *

    This will return all of the counties whose boundaries intersect the state graphic and are contained within it.

  7. Bring up the Spatial Matrix tool and click on the center left cell Twice (F - False) and the center cell once (T - True).

    * * *

    F T *

    * * *

    This will return all of the counties that share a boundary with the State graphic and are not contained within it.

  8. Bring up the Spatial Matrix tool and click on the top center cell twice (F - False) and the center left cell once (T - True).

    * F *

    * T *

    * * *

    This will return all of the counties that share a boundary with the State graphic and are not contained within it.

Application:
ArcMap

Requires: US States and Counties data - recommended

Difficulty: Intermediate


Visual Basic
File Description
RelateTool.cls VB class file.
RelateForm.frm VB form file.
RelateTool.vbp VB Project File for sample.


Key Interfaces: ISpatialFilter, IFeatureClass