ST_Envelope¶
Returns the bounding box (envelope) of a geometry or geography as a new geometry.
Usage¶
geometry ST_Envelope(geom: geometry)
geometry ST_Envelope(geog: geography)
Arguments¶
- geog (geography): Input geography
- geom (geometry): Input geometry
Description¶
Returns the minimum axis-aligned bounding box of a geometry. This is usually a polygon but can be a linestring for perfectly vertical or horizontal input and is a point if the input is also a point. For geography, the return value is still a rectangular polygon geometry that represents the latitude and longitude range of the input. For geographies that span the antimeridian, a multipolygon is returned (one on each side of the antimeridian).
Because of slight numerical inaccuracy of geographical calculations, the bounds are expanded slightly compared to the corresponding geometry envelope.
Examples¶
SELECT ST_Envelope(ST_Point(1.0, 2.0));
┌──────────────────────────────────────────────┐
│ st_envelope(st_point(Float64(1),Float64(2))) │
│ geometry │
╞══════════════════════════════════════════════╡
│ POINT(1 2) │
└──────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeomFromWKT('LINESTRING(0 0, 3 4)'));
┌───────────────────────────────────────────────────────────┐
│ st_envelope(st_geomfromwkt(Utf8("LINESTRING(0 0, 3 4)"))) │
│ geometry │
╞═══════════════════════════════════════════════════════════╡
│ POLYGON((0 0,0 4,3 4,3 0,0 0)) │
└───────────────────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeogFromWKT('LINESTRING(0 0, 3 4)'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_envelope(st_geogfromwkt(Utf8("LINESTRING(0 0, 3 4)"))) │
│ geometry │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 -0.000000000000025444437451708134,0 4.000000000000026,3.00000000… │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeomFromWKT('LINESTRING(170 3, -170 4)'));
┌────────────────────────────────────────────────────────────────┐
│ st_envelope(st_geomfromwkt(Utf8("LINESTRING(170 3, -170 4)"))) │
│ geometry │
╞════════════════════════════════════════════════════════════════╡
│ POLYGON((-170 3,-170 4,170 4,170 3,-170 3)) │
└────────────────────────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeogPoint(1.0, 2.0));
┌───────────────────────────────────────────────────────┐
│ st_envelope(st_geogpoint(Float64(1),Float64(2))) │
│ geometry │
╞═══════════════════════════════════════════════════════╡
│ LINESTRING(0.9999999999999746 2,1.0000000000000255 2) │
└───────────────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeogFromWKT('LINESTRING(0 0, 3 4)'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_envelope(st_geogfromwkt(Utf8("LINESTRING(0 0, 3 4)"))) │
│ geometry │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 -0.000000000000025444437451708134,0 4.000000000000026,3.00000000… │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_Envelope(ST_GeogFromWKT('LINESTRING(170 3, -170 4)'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_envelope(st_geogfromwkt(Utf8("LINESTRING(170 3, -170 4)"))) │
│ geometry │
╞══════════════════════════════════════════════════════════════════════════════╡
│ MULTIPOLYGON(((170 2.9999999999999747,170 4.000000000000026,180 4.000000000… │
└──────────────────────────────────────────────────────────────────────────────┘