SQL Server 2008 Books Online (October 2009)
Polygon

A Polygon is a two-dimensional surface stored as a sequence of points defining an exterior bounding ring and zero or more interior rings. A Polygon instance can be formed from a ring that has at least three distinct points. A Polygon instance can also be empty.

The exterior and any interior rings of a Polygon define its boundary. The space within the rings defines the interior of the Polygon. The interior rings of a Polygon can touch both themselves and each other at single tangent points, but if the interior rings of a Polygon cross, the instance is not valid.

Examples

The illustration below shows examples of Polygon instances.

Examples of geometry Polygon instances

As shown in the illustration:

  1. Figure 1 is a Polygon instance whose boundary is defined by an exterior ring.
  2. Figure 2 is a Polygon instance whose boundary is defined by an exterior ring and two interior rings. The area inside the interior rings is part of the exterior of the Polygon instance.
  3. Figure 3 is a valid Polygon instance because its interior rings intersect at a single tangent point.

The following example creates a simple geometry Polygon instance with a hole and SRID 10.

DECLARE @g geometry;
SET @g = geometry::STPolyFromText('POLYGON((0 0, 0 3, 3 3, 3 0, 0 0), (1 1, 1 2, 2 1, 1 1))', 10);

An instance that is not valid may be entered and converted to a valid geometry instance. In the following example of a Polygon, the interior and exterior rings overlap and the instance is not valid.

DECLARE @g geometry;
SET @g = geometry::Parse('POLYGON((1 0, 0 1, 1 2, 2 1, 1 0), (2 0, 1 1, 2 2, 3 1, 2 0))');

In the following example, the invalid instance is made valid with MakeValid().

SET @g = @g.MakeValid();
SELECT @g.ToString();

The geometry instance returned from the above example is a MultiPolygon.

MULTIPOLYGON (((2 0, 3 1, 2 2, 1.5 1.5, 2 1, 1.5 0.5, 2 0)), ((1 0, 1.5 0.5, 1 1, 1.5 1.5, 1 2, 0 1, 1 0)))
See Also

Concepts

MultiPolygon
Designing and Implementing Spatial Storage (Database Engine)

Other Resources

STArea (geometry Data Type)
STExteriorRing (geometry Data Type)
STNumInteriorRing (geometry Data Type)
STInteriorRingN (geometry Data Type)
STCentroid (geometry Data Type)
STPointOnSurface (geometry Data Type)

Help and Information

Getting SQL Server 2008 Assistance
Tags :


Page view tracker