ST_MakeEnvelope

更新时间:
复制 MD 格式

Constructs a rectangular polygon (bounding box) from the specified minimum and maximum coordinate values.

Syntax

geometry ST_MakeEnvelope(double precision xmin, double precision ymin, double precision xmax, double precision ymax, integer srid)

Parameters

ParameterTypeDescription
xmindouble precisionThe minimum x coordinate.
ymindouble precisionThe minimum y coordinate.
xmaxdouble precisionThe maximum x coordinate.
ymaxdouble precisionThe maximum y coordinate.
sridintegerThe spatial reference identifier (SRID) that defines the coordinate system for the polygon. Default value: 0 (unknown).

Usage notes

The coordinate values must fall within the value range supported by the specified SRID.

Example: Build a bounding box polygon

SELECT ST_AsText(ST_MakeEnvelope(1, 2, 3, 4, 4326));

Output:

           st_astext
--------------------------------
 POLYGON((1 2,1 4,3 4,3 2,1 2))
(1 row)