STIntersection (geography Data Type)

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance

Returns an object that represents the points where a geography instance intersects another geography instance.

Syntax

  
.STIntersection ( other_geography )  

Note

To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions documentation.

Arguments

other_geography
Is another geography instance to compare with the instance on which STIntersection() is being invoked.

Return Types

SQL Server return type: geography

CLR return type: SqlGeography

Remarks

The intersection of two geography instances is returned.

STIntersection() always returns null if the spatial reference identifiers (SRIDs) of the geography instances do not match.

SQL Server supports spatial instances that are larger than a hemisphere. SQL Server may include FullGlobe instances in the set of possible results returned on the server.

The result may contain circular arc segments only if the input instances contain circular arc segments.

Examples

A. Computing the intersection of a Polygon and a LineString

The following example uses STIntersection() to compute the intersection of a Polygon and a LineString.

DECLARE @g geography;  
DECLARE @h geography;  
SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);  
SET @h = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);  
SELECT @g.STIntersection(@h).ToString();  

B. Computing the intersection of a Polygon and a CurvePolygon

The following example returns an instance that contains a circular arc segment.

DECLARE @g geography;  
DECLARE @h geography;  
SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);  
SET @h = geography::STGeomFromText('CURVEPOLYGON(CIRCULARSTRING(-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326);  
SELECT @g.STIntersection(@h).ToString();  

C. Computing the symmetric difference with FullGlobe

The following example compares the symmetric difference of a Polygon with FullGlobe.

DECLARE @g geography = 'POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))';  
SELECT @g.STIntersection('FULLGLOBE').ToString();  

See Also

OGC Methods on Geography Instances