Export (0) Print
Expand All

STIntersection (geography Data Type)

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.

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();
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft