ST_BoundingDiagonal
Name
ST_BoundingDiagonal — Returns the diagonal of the supplied geometry's bounding box.
Synopsis
geometry
ST_BoundingDiagonal
(
geometry
geom
, boolean
fits=false
)
;
Description
Returns the diagonal of the supplied geometry's bounding box as linestring. If the input geometry is empty, the diagonal line is also empty, otherwise it is a 2-points linestring with minimum values of each dimension in its start point and maximum values in its end point.
The returned linestring geometry always retains SRID and dimensionality (Z and M presence) of the input geometry.
The
fits
parameter specifies if the best fit is needed.
If false, the diagonal of a somewhat larger bounding box can be accepted
(is faster to obtain for geometries with a lot of vertices). In any case
the bounding box of the returned diagonal line always covers the input
geometry.
![]() |
|
In degenerate cases (a single vertex in input) the returned linestring will be topologically invalid (no interior). This does not make the return semantically invalid. |
Availability: 2.2.0
This function supports 3d and will not drop the z-index.
This function supports M coordinates.