Properties of spatial data types
Typically, points represent an object at a single location, linestrings represent a linear characteristic, and polygons represent a spatial extent.
The OGC, in its publication of OpenGIS Features for ODBC (SQL) Implementation Specification, selected the term geometry to represent spatial features such as point locations and polygons. An abstract definition of the OpenGIS noun geometry might be, “a point or aggregate of points symbolizing a feature on the ground.”
Descriptions of the properties of the spatial data types follow. Each subclass data type inherits the properties of the ST_Geometry superclass and adds properties of its own. Functions that operate on the ST_Geometry data type also operate on any of the subclass data types. However, functions that are defined at the subclass level operate only on that data type and its subclasses data types.
- Interior, boundary, and exterior
All geometries occupy a position in space that is defined by their interior, boundary, and exterior.
- Exterior
- All space that is not occupied by the geometry.
- Boundary
- Serves as the interface between its interior and exterior.
- Interior
- The space that is occupied by the geometry.
The subclass inherits the interior and exterior properties from ST_Geometry; the boundary property differs for each data type.
The ST_Boundary() function takes an ST_Geometry type and returns an ST_Geometry that represents the source ST_Geometry boundary.
- Simple or nonsimple
Some subclasses of ST_Geometry (ST_LineStrings, ST_MultiPoints, and ST_MultiLineStrings) are either simple or nonsimple. They are simple if they obey all topological rules that are imposed on the subclass and nonsimple if they bend a few rules.
- ST_LineString is simple if it does not intersect its interior.
- ST_MultiPoint is simple if none of its elements occupy the same coordinate space.
- ST_MultiLineString is simple if none of its element's interiors intersect.
The ST_IsSimple() function takes an ST_Geometry and returns t (TRUE) if the ST_Geometry is simple and f (FALSE), otherwise.
- Empty or not empty
- A geometry is empty if it does not have any points.
An empty geometry has a NULL envelope, boundary, interior, and exterior. An empty geometry is always simple and can have Z coordinates or measures. Empty linestrings and multilinestrings have a 0 length. Empty polygons and multipolygons have 0 area.
The ST_IsEmpty() function takes an ST_Geometry and returns t (TRUE) if the ST_Geometry is empty and f (FALSE) otherwise.
- Number of points
- A geometry can have zero or more points.
A geometry is considered empty if it has zero points. The ST_Point subclass is the only geometry that is restricted to zero or one point; all other subclasses can have zero or more.
- Envelope
- The envelope of a geometry is the bounding geometry that is formed
by the minimum and maximum (X,Y) coordinates.
The envelopes of most geometries form a boundary rectangle. However, the envelope of a point is the point itself, since its minimum and maximum coordinates are the same. The envelope of a horizontal or vertical linestring is a linestring that is represented by the endpoints of the source linestring.
The ST_Envelope() function takes an ST_Geometry and returns a ST_Geometry that represents the source ST_Geometry envelope.
- Dimension
- A geometry can have a dimension of 0, 1, or 2.
- 0
- The geometry has neither length or area.
- 1
- The geometry has a length.
- 2
- The geometry contains area.
The point and multipoint subclasses have a dimension of 0. Points represent zero-dimensional features that can be modeled with a single coordinate, while multipoints represent data that must be modeled as a cluster of unconnected coordinates.
The subclasses linestring and multilinestring have a dimension of 1. They store road segments, branching river systems, and any other features that are linear in nature.
Polygon and multipolygon subclasses have a dimension of 2. Forest stands, parcels, water bodies, and other features whose perimeter encloses a definable area can be rendered by either the polygon or multipolygon data type.
Dimension is important not only as a property of the subclass, but also plays a part in determining the spatial relationship of two features. The dimension of the resulting feature or features determines whether the operation was successful. The dimension of the features is examined to determine how they are compared.
The ST_Dimension() function takes an ST_Geometry and returns its dimension as an integer.
- Z coordinates
- Some geometries have an associated altitude or depth.
Each of the points that form the geometry of a feature can include an optional Z coordinate that represents an altitude or depth normal to the earth's surface.
The SE_Is3D() predicate function takes an ST_Geometry and returns t (TRUE) if the function has Z coordinates and f (FALSE), otherwise.
- Measures
- Measures are values that are assigned to each coordinate.
The value represents anything that can be stored as a double-precision number.
The SE_IsMeasured() function takes an ST_Geometry and returns t (TRUE) if it contains measures and f (FALSE), otherwise.
- Spatial reference system
- The spatial reference system identifies the coordinate transformation
matrix for each geometry.
All spatial reference systems that are known to the database are stored in the spatial_references table.
The ST_SRID() function takes an ST_Geometry and returns its spatial reference identifier as an integer.