Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 3.16 KB

stunion-geography-data-type.md

File metadata and controls

87 lines (65 loc) · 3.16 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs
STUnion (geography Data Type)
STUnion (geography Data Type)
MladjoA
mlandzic
03/14/2017
sql
t-sql
reference
ignite-2024
STUnion (geography Data Type)
STUnion_TSQL
STUnion method
TSQL

STUnion (geography Data Type)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]

Returns an object that represents the union of a geography instance with another geography instance.

Syntax

  
.STUnion ( other_geography )  

Arguments

other_geography
Is another geography instance to form a union with the instance on which STUnion() is being invoked.

Return Types

[!INCLUDEssNoVersion] return type: geography

CLR return type: SqlGeography

Exceptions

This method throws an ArgumentException if the instance contains an antipodal edge.

Remarks

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

[!INCLUDEssNoVersion] supports spatial instances that are larger than a hemisphere. In [!INCLUDEssNoVersion], the set of possible results returned on the server has been extended to FullGlobe instances.

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

This method is not precise.

Examples

A. Computing the union of two polygons

The following example uses STUnion() to compute the union of two Polygon instances.

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('POLYGON((-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326);  
SELECT @g.STUnion(@h).ToString();  

B. Producing a FullGlobe result

The following example produces a FullGlobe when STUnion() combines two Polygon instances.

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

C. Producing a triagonal hole from a union of a CurvePolygon and a triagonal hole.

The following example produces a triagonal hole from the union of a CurvePolygon with a Polygon instance.

 DECLARE @g geography = 'POLYGON ((-0.5 0, 0 1, 0.5 0.5, -0.5 0))';  
 DECLARE @h geography = 'CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0, 0.7 0.7, 0 1), (0 1, 0 0)))';  
 SELECT @g.STUnion(@h).ToString();

See Also

OGC Methods on Geography Instances