# Querying Properties and Behaviors of geometry Instances

All geometry instances have a number of properties that can be retrieved through methods that SQL Server provides. The following topics define the properties and behaviors of geometry types, and the methods for querying each one.

All nonempty geometry instances are comprised of points. These points represent the X- and Y-coordinates of the plane on which the geometries are drawn. geometry provides numerous built-in methods for querying the points of an instance.

#### To return the number of points that comprise an instance

#### To return a specific point in an instance

#### To return an arbitrary point that lies on an instance

#### To return the start point of an instance

#### To return the end point of an instance

#### To return the X-coordinate of a Point instance

#### To return the Y-coordinate of a Point instance

#### To return the geometric center point of a Polygon or MultiPolygon instance

A nonempty geometry instance can be 0-, 1-, or 2-dimensional. Zero-dimensional geometries, such as Point and MultiPoint, have no length or area. One-dimensional objects, such as LineString and MultiLineString, have length. Two-dimensional instances, such as Polygon and MultiPolygon, have area and length. Empty instances will report a dimension of -1, and a GeometryCollection will report an area dependent on the types of its contents.

#### To return the dimension of an instance

#### To return the length of an instance

#### To return the area of an instance

For a geometry of the instance to be simple, it must meet both of these requirements:

Each figure of the instance must not intersect itself, except at its endpoints.

No two figures of the instance can intersect each other at a point that is not in both of their boundaries.

Note |
---|

Empty geometries are always simple. |

#### To determine if an instance is simple

The interior of a geometry instance is the space occupied by the instance, and the exterior is the space not occupied it.

Boundary is defined by the OGC as follows:

Point and MultiPoint instances do not have a boundary.

LineString and MultiLineString boundaries are formed by the start points and end points, removing those that occur an even number of times.

DECLARE @g geometry; SET @g = geometry::Parse('MULTILINESTRING((0 1, 0 0, 1 0, 0 1), (1 1, 1 0))'); SELECT @g.STBoundary().ToString();

The boundary of a Polygon or MultiPolygon instance is the set of its rings.

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

To return the boundary of an instance

A closed geometry instance is a figure whose start points and end points are the same. Polygon instances are considered closed. Point instances are not closed.

A ring is a simple, closed LineString instance.

To determine if an instance is closed

To determine if an instance is a ring

To return the exterior ring of a Polygon instance

To return the number of interior rings in a Polygon

To return a specified interior ring of a Polygon