What is the ST_Geometry storage type?

The ST_Geometry data type implements the SQL 3 specification of user-defined data types (UDTs), allowing you to create columns capable of storing spatial data such as the location of a landmark, a street, or a parcel of land. It provides International Organization for Standards (ISO) and Open Geospatial Consortium, Inc. (OGC) compliant structured query language (SQL) access to the geodatabase and database. This storage extends the capabilities of the database by providing storage for objects (points, lines, and polygons) that represent geographic features. It was designed to make efficient use of database resources; to be compatible with database features such as replication and partitioning; and to provide rapid access to spatial data.

ST_Geometry itself is an abstract, noninstantiated superclass. However, its subclasses can be instantiated. An instantiated data type is one that can be defined as a table column and have values of its type inserted into it.

Although you can define a column as type ST_Geometry, you do not insert ST_Geometry values into the column since it cannot be instantiated. Instead, you insert the subclass values.

The following chart demonstrates the hierarchy of the ST_Geometry data type and its subclasses.

ST_Geometry
The ST_Geometry superclass and its subclasses

Subclasses

ST_Geometry's subclasses are divided into two categories: the base geometry subclasses and the homogeneous collection subclasses. The base geometries include ST_Point, ST_LineString, and ST_Polygon, while the homogeneous collections include ST_MultiPoint, ST_MultiLineString, and ST_MultiPolygon. As the names imply, the homogeneous collections are collections of base geometries. In addition to sharing base geometry properties, homogeneous collections have some of their own properties.

Each subclass stores the type of geometry implied by its name; for instance, ST_MultiPoint stores multipoints. A list of the subclasses and their descriptions are in the following table:

Subtype

Description

ST_Point

  • A zero-dimensional geometry that occupies a single location in coordinate space
  • Has a single x,y coordinate value, is always simple, and has a NULL boundary

ST_LineString

  • A one-dimensional object stored as a sequence of points defining a linear interpolated path
  • ST_LineStrings have length.
  • The ST_LineString is simple if it does not intersect its interior.
  • The endpoints (the boundary) of a closed ST_LineString occupy the same point in space.
  • An ST_LineString is a ring if it is both closed and simple.
  • The endpoints normally form the boundary of an ST_LineString unless the ST_LineString is closed, in which case the boundary is NULL.
  • The interior of an ST_LineString is the connected path that lies between the endpoints, unless it is closed, in which case the interior is continuous.

ST_Polygon

  • A two-dimensional surface stored as a sequence of points defining its exterior bounding ring and zero or more interior rings
  • ST_Polygon has area and is always simple.
  • The exterior and any interior rings define the boundary of an ST_Polygon, and the space enclosed between the rings defines the ST_Polygon's interior.
  • The rings of an ST_Polygon can intersect at a tangent point but never cross.

ST_MultiPoint

  • A collection of ST_Points
  • Has a dimension of 0
  • An ST_MultiPoint is simple if none of its elements occupy the same coordinate space.
  • The boundary of an ST_MultiPoint is NULL.

ST_MultiLineString

  • A collection of ST_LineStrings
  • ST_MultiLineStrings have length.
  • ST_MultiLineStrings are simple if they only intersect at the endpoints of the ST_LineString elements.
  • ST_MultiLineStrings are nonsimple if the interiors of the ST_LineString elements intersect.
  • The boundary of an ST_MultiLineString is the nonintersected endpoints of the ST_LineString elements.
  • The ST_MultiLineString is closed if all of its ST_LineString elements are closed.
  • The boundary of an ST_MultiLineString is NULL if all the endpoints of all the elements are intersected.

ST_MultiPolygon

  • A collection of polygons
  • ST_MultiPolygons have area.
  • The boundary of an ST_MultiPolygon is the cumulative length of its elements' exterior and interior rings.
  • The interior of an ST_MultiPolygon is defined as the cumulative interiors of its element ST_Polygons.
  • The boundary of an ST_MultiPolygon's elements can only intersect at a tangent point.

ST_Geometry subtypes

Note that each subclass inherits the properties of the ST_Geometry superclass but also has properties of its own. Functions that operate on the ST_Geometry data type accept any of the subclass entity types. However, some functions have been defined at the subclass level and only accept certain subclasses. For example, the ST_GeometryN function only takes ST_MultiLinestring, ST_MultiPoint, or ST_MultiPolygon subtype values as input.

To discover the subclass of an ST_Geometry, you can use the ST_GeometryType function. The ST_GeometryType function takes an ST_Geometry and returns the instantiated subclass in the form of a character string. To find out how many base geometry elements are contained in a homogeneous collection, you can use the ST_NumGeometries function, which takes a homogeneous collection and returns the number of base geometry elements it contains.

8/21/2013