Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
STIntersection (geography Data Type)

STIntersection (geography Data Type)

 

Applies To: SQL Server 2014, SQL Server 2016 Preview

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

Applies to: SQL Server (SQL Server 2012 through current version), Azure SQL Database.


.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.

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

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

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

Community Additions

ADD
Show:
© 2015 Microsoft