Spatial relationships
A primary function of a GIS is to determine the spatial relationships between features: Do they overlap? Is one contained by the other? Does one cross the other?
Geometries can be spatially related in different ways. The following are examples of how one geometry can be spatially related to another:
- Geometry A passes through geometry B.
- Geometry A is completely contained by geometry B.
- Geometry A completely contains geometry B.
- The geometries do not intersect or touch one another.
- The geometries are completely coincident.
- The geometries overlap each other.
- The geometries touch at one point.
To determine whether these relationships exist or not, execute spatial relationship functions. These functions compare the following properties of the geometries you specify in your query:
- The exteriors (E) of the geometries, which is all of the space not occupied by a geometry
- The interior (I) of the geometries, which is the space occupied by a geometry
- The boundary (B) of the geometries, which is the interface between a geometry's interior and exterior
When you construct a spatial relationship query, specify the type of spatial relationship you are looking for and the geometries you want to compare. The queries return as either true or false; either the geometries participate with one another in the specified spatial relationship or they do not. In most cases, you would use a spatial relationship query to filter a result set by placing it in the WHERE clause.
For example, if you have a table that stores the locations of proposed development sites and another table that stores the location of archaeologically significant sites, you might want to make sure that the features in the development sites table do not intersect the archaeological sites. You could issue a query to make sure none of the development sites intersect archaeology sites and, if any do, return the ID of those proposed developments. In this example, the ST_Disjoint function is used.
SELECT d.projname,a.siteid FROM dev d, archsites a WHERE sde.st_disjoint(d.shape,a.shape)= 'f' projname siteid bow wow chow A1009
This query returns the name of the development and the ID of the archaeological site that are not disjoint—in other words, the sites that intersect one another. It returns one development project, Bow Wow Chow, which intersects archaeological site A1009.
For information on ST_Geometry functions that test spatial relationships in Oracle or PostgreSQL, see Spatial relationship functions for ST_Geometry. For information on spatial relationship functions used with IBM DB2, IBM Informix, Oracle Spatial, PostGIS, or Microsoft SQL Server spatial types, see the documentation for those database management systems.