Sie sind auf Seite 1von 2

PostGIS 1.5.

1 Manual
259 / 315

Note
Pre 1.3, ST_Expand was used in conjunction with distance to do indexable queries.
Something of
the form the_geom && ST_Expand(POINT(10 20), 10) AND ST_Distance(the_geom, POINT(10 20)) < 10 Post 1.2, this was replaced with the easier ST_DWithin construct.

Note
Bounding boxes of all geometries are currently 2-d even if they are 3-dimensional geometries.

Note
Availability: 1.5.0 behavior changed to output double precision instead of float4 coordinates.

Examples

Note
Examples below use US National Atlas Equal Area (SRID=2163) which is a meter projection

--10 meter expanded box around bbox of a linestring


SELECT CAST(ST_Expand(ST_GeomFromText(LINESTRING(2312980 110676,2312923 110701,2312892
110714), 2163),10) As box2d);
st_expand
-----------------------------------BOX(2312882 110666,2312990 110724)

--10 meter expanded 3d box of a 3d box


SELECT ST_Expand(CAST(BOX3D(778783 2951741 1,794875 2970042.61545891 10) As box3d),10)
st_expand
----------------------------------------------------BOX3D(778773 2951731 -9,794885 2970052.61545891 20)
--10 meter geometry astext rep of a expand box around a point geometry
SELECT ST_AsEWKT(ST_Expand(ST_GeomFromEWKT(SRID=2163;POINT(2312980 110676)),10));
st_asewkt
------------------------------------------------------------------------------------------------- SRID=2163;POLYGON((2312970 110666,2312970 110686,2312990 110686,2312990 110666,2312970
110666))

See Also
ST_AsEWKT, ST_Buffer, ST_DWithin, ST_GeomFromEWKT,ST_GeomFromText, ST_SRID

7.12.6 ST_Extent
Name
ST_Extent an aggregate function that returns the bounding box that bounds rows of geometries.

PostGIS 1.5.1 Manual


260 / 315

Synopsis
box3d_extent ST_Extent(geometry set geomfield);

Description
ST_Extent returns a bounding box that encloses a set of geometries. The ST_Extent function is an "aggregate" function in the
terminology of SQL. That means that it operates on lists of data, in the same way the SUM() and AVG() functions do.
Since it returns a bounding box, the spatial Units are in the units of the spatial reference system in use denoted by the SRID
ST_Extent is similar in concept to Oracle Spatial/Locators SDO_AGGR_MBR

Note
Since ST_Extent returns a bounding box, the SRID meta-data is lost. Use ST_SetSRID to force it back into a geometry
with SRID meta data. The coordinates are in the units of the spatial ref of the orginal geometries.

Note
ST_Extent will return boxes with only an x and y component even with (x,y,z) coordinate geometries. To maintain x,y,z
use ST_Extent3D instead.

Note
Availability: 1.4.0 As of 1.4.0 now returns a box3d_extent instead of box2d object.

Examples

Note
Examples below use Massachusetts State Plane ft (SRID=2249)

SELECT ST_Extent(the_geom) as bextent FROM sometable;


st_bextent
-----------------------------------BOX(739651.875 2908247.25,794875.8125 2970042.75)

--Return extent of each category of geometries


SELECT ST_Extent(the_geom) as bextent
FROM sometable
GROUP BY category ORDER BY category;
bextent
|
name
----------------------------------------------------+---------------BOX(778783.5625 2951741.25,794875.8125 2970042.75) | A
BOX(751315.8125 2919164.75,765202.6875 2935417.25) | B
BOX(739651.875 2917394.75,756688.375 2935866)
| C
--Force back into a geometry

Das könnte Ihnen auch gefallen