Test if a geometry value spatially intersects another value.
geometry-expression.ST_Intersects(geo2)
Name | Type | Description |
---|---|---|
geo2 |
ST_Geometry |
The other geometry value that is to be compared to the geometry-expression. |
Returns 1 if the geometry-expression spatially intersects with geo2, otherwise 0.
Tests if a geometry value spatially intersects another value. Two geometries intersect if they share one or more common points.
geometry-expression.ST_Intersects( geo2 ) = 1 is equivalent to geometry-expression.ST_Disjoint( geo2 ) = 0.
5.1.27
The following example returns a result with one row for each shape that intersects the specified line.
SELECT ShapeID, "Description" FROM SpatialShapes WHERE NEW ST_LineString( 'LineString( 2 2, 4 4 )' ).ST_Intersects( Shape ) = 1 ORDER BY ShapeID
The example returns the following result set:
ShapeID | Description |
---|---|
2 | Square |
3 | Rectangle |
5 | L shape line |
18 | CircularString |
22 | Triangle |
The following query returns the intersection of the geometries in the SpatialShapes table:
SELECT Shape FROM SpatialShapes WHERE NEW ST_LineString( 'LineString( 2 2, 4 4 )' ).ST_Intersects( Shape ) = 1 UNION ALL SELECT NEW ST_LineString( 'LineString( 2 2, 4 4 )' )
The following returns the result 1 because the two linestrings intersect.
SELECT NEW ST_LineString('LineString(0 0,2 0)').ST_Intersects( NEW ST_LineString('LineString(1 -1,1 1)') )
The following returns the result 0 because the two linestrings do not intersect.
SELECT NEW ST_LineString('LineString(0 0,2 0)').ST_Intersects( NEW ST_LineString('LineString(1 1,1 2)') )