PostGIS Geometry/Geography/Box Data TypesThis section lists the custom PostgreSQL
data types installed by PostGIS to represent spatial data.
Each data type describes its type casting behavior.
A type cast
converts values of one data type into another type.
PostgreSQL allows defining casting behavior for custom types, along with the functions used to convert type values.
Casts can have automatic behavior,
which allows automatic conversion of a function argument to a type supported by the function.
Some casts have explicit behavior,
which means the cast must be specified using the syntax CAST(myval As sometype)
or myval::sometype.
Explicit casting avoids the issue of ambiguous casts,
which can occur when using an overloaded function which does not support a given type.
For example, a function may accept a box2d or a box3d, but not a geometry.
Since geometry has an automatic cast to both box types, this produces an "ambiguous function" error.
To prevent the error use an explicit cast to the desired box type.All data types can be cast to text, so this does not need to be specified explicitly.box2dThe type representing a 2-dimensional bounding box. Descriptionbox2d is a spatial data type used to represent
the two-dimensional bounding box enclosing a geometry or collection of geometries.
For example, the aggregate function returns a box2d object.The representation contains the values xmin, ymin, xmax, ymax.
These are the minimum and maximum values of the X and Y extents.
box2d objects have a text representation which looks like BOX(1 2,5 6).
Casting BehaviorThis table lists the automatic and explicit casts allowed for this data type:Cast ToBehaviorbox3dautomaticgeometryautomaticSee Alsobox3dThe type representing a 3-dimensional bounding box. Descriptionbox3d is a PostGIS spatial data type used to represent
the three-dimensional bounding box enclosing a geometry or collection of geometries.
For example, the aggregate function returns a box3d object.
The representation contains the values xmin, ymin, zmin, xmax, ymax, zmax.
These are the minimum and maximum values of the X, Y and Z extents.
box3d objects have a text representation which looks like BOX3D(1 2 3,5 6 5).
Casting BehaviorThis table lists the automatic and explicit casts allowed for this data type:Cast ToBehaviorboxautomaticbox2dautomaticgeometryautomaticSee AlsogeometryThe type representing spatial features with planar coordinate systems.Descriptiongeometry is a fundamental PostGIS spatial data type used to represent a feature in planar (Euclidean) coordinate systems.All spatial operations on geometry use the units of the Spatial Reference System the geometry is in.Casting BehaviorThis table lists the automatic and explicit casts allowed for this data type:Cast ToBehaviorboxautomaticbox2dautomaticbox3dautomaticbyteaautomaticgeographyautomatictextautomaticSee Also, geometry_dumpA composite type used to describe the parts of complex geometry.Descriptiongeometry_dump is a
composite data type
containing the fields:geom - a geometry representing a component of the dumped geometry.
The geometry type depends on the originating function.path[] - an integer array
that defines the navigation path within the dumped geometry to the geom component.
The path array is 1-based (i.e. path[1] is the first element.)
It is used by the ST_Dump* family of functions as an output type to explode a complex geometry into its
constituent parts.See AlsogeographyThe type representing spatial features with geodetic (ellipsoidal) coordinate systems.Descriptiongeography is a spatial data type used to represent a feature in geodetic coordinate systems.
Geodetic coordinate systems model the earth using an ellipsoid.
Spatial operations on the geography type provide more accurate results
by taking the ellipsoidal model into account.
Casting BehaviorThis table lists the automatic and explicit casts allowed for this data type:Cast ToBehaviorgeometryexplicitSee Also,