跳转至
Apache Sedona 1.9.0 已正式发布,新增 Spark 4.1 支持、proj4sedona 坐标系转换、Bing Tile 函数等众多特性!

ST_GeomFromBox2D

Introduction: Convert a Box2D to a closed rectangular polygon Geometry. Equivalent to PostGIS box2d::geometry. Degenerate boxes return the appropriate lower-dimensional geometry:

Box2D shape Returned geometry
Both axes have non-zero extent POLYGON (closed rectangle)
One axis collapsed (e.g. xmin == xmax) LINESTRING along the non-collapsed axis
Both axes collapsed (xmin == xmax && ymin == ymax) POINT

Format: ST_GeomFromBox2D(box: Box2D)

Return type: Geometry

Since: v1.9.1

SQL Example

SELECT ST_AsText(ST_GeomFromBox2D(ST_MakeBox2D(ST_Point(0.0, 0.0), ST_Point(2.0, 4.0))))

Output:

POLYGON ((0 0, 0 4, 2 4, 2 0, 0 0))

ST_GeomFromBox2D is also produced by the SQL cast CAST(box AS geometry) — see Type conversion.

Returns NULL on NULL input.