This section lists the custom PostgreSQL
data types installed by PostGIS to represent spatial data.
Each data type describes its type casting behaviour.
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 behaviour,
which allows automatic conversion of a function argument to a type supported by the function.
Some casts have explicit behaviour,
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.
PostGIS Geometry/Geography/Box Data Types
box2d
A 2-dimensional bounding box.
Used to describe the 2D extent of a geometry or collection of geometries.
Description
box2d is a spatial data type used to represent
the two-dimensional enclosing box of 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 maxium values of the X and Y extents.
See Also
box3d
A 3-dimensional bounding box.
Used to describe the 3D extent of a geometry or collection of geometries.
Description
box3d is a postgis spatial data type used to represent
the three-dimensional enclosing box of 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 maxium values of the X, Y and Z extents.
Casting Behavior
This section lists the automatic as well as explicit casts allowed for this data type
Cast To
Behavior

box
automatic

box2d
automatic

geometry
automatic

See Also
geometry
The type representing spatial features with planar coordinate systems.
Description
geometry 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 Behavior
This section lists the automatic as well as explicit casts allowed for this data type
Cast To
Behavior

box
automatic

box2d
automatic

box3d
automatic

bytea
automatic

geography
automatic

text
automatic

See Also
,
geometry_dump
A composite type used to describe the parts of complex geometry.
Description
geometry_dump is a
composite data type
containing the fields:
geom - a references to a component geometry
path[] - a 1-dimensional integer array
that defines the navigation path within the dumped geometry to the geom component.
The path array starts at 1 (e.g. 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 Also
geography
The type representing spatial features with geodetic (ellipsoidal) coordinate systems.
Description
geography 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 Behavior
This section lists the automatic as well as explicit casts allowed for this data type
Cast To
Behavior

geometry
explicit

See Also
,