STIntersection (geography Data Type)

 

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2012)yesAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

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

  
.STIntersection ( other_geography )  

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

SQL Server return type: geography

CLR return type: SqlGeography

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.

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();  

OGC Methods on Geography Instances

Community Additions

ADD
Show: