ST_Crosses takes two geometry objects and returns 1 (TRUE) if their intersection results in a geometry object whose dimension is one less than the maximum dimension of the source objects. The intersection object contains points that are interior to both source geometries and is not equal to either of the source objects. Otherwise it returns 0 (FALSE).
Syntax
db2gse.ST_Crosses(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)
Return type
Integer
Examples
The county government is considering a new regulation that states that all hazardous waste storage facilities within the county cannot be within five miles of any waterway. The county GIS manager has an accurate representation of rivers and streams, which are stored as multilinestrings in the WATERWAYS table. But, the GIS manager has only a single point location for each of the hazardous waste storage facilities.
CREATE TABLE WATERWAYS (id integer, name varchar(128), water db2gse.ST_MultiLineString); CREATE TABLE HAZARDOUS_SITES ( site_id integer, name varchar(128), location db2gse.ST_Point);
To determine if the county supervisor needs to be alerted to facilities that violate the proposed regulation, the GIS manager should buffer the hazardous site locations and see if any rivers or streams cross the buffer polygon. The ST_Crosses predicate compares the buffered HAZARDOUS_SITES with WATERWAYS. So, only those records in which the waterway crosses over the county's proposed regulated radius are returned.
SELECT ww.name "River or stream", hs.name "Hazardous site" FROM WATERWAYS ww, HAZARDOUS_SITES hs WHERE db2gse.ST_Crosses(db2gse.ST_Buffer(hs.location,(5 * 5280)),ww.water) = 1;
In Figure 31, the five-mile buffer of the hazardous waste sites crosses the stream network that runs through the county's administrative district. The stream network has been defined as a multilinestring. So, the result set includes all linestring segments that are part of those segments that cross the radius.
Figure 31. Using ST_Crosses to find the waterways that pass through a hazardous waste area