ST_Buffer takes a geometry, a distance, and, optionally, a unit as input parameters and returns the geometry that surrounds the given geometry by the specified distance, measured in the given unit.
Each point on the boundary of the resulting geometry is the specified distance away from the given geometry. The resulting geometry is represented in the spatial reference system of the given geometry.
For geodetic data, if you specify a negative distance, ST_Buffer returns a region that is further than the specified distance away from all points of the input geometry. In other words, a negative distance returns the complementary region.
Any circular curve in the boundary of the resulting geometry is approximated by linear strings. For example, the buffer around a point, which would result in a circular region, is approximated by a polygon whose boundary is a linestring.
If the given geometry is null or is empty, null will be returned.
This function can also be called as a method.
db2gse.ST_Geometry
In the following examples, the results have been reformatted for readability. The spacing in your results will vary according to your display.
Example 1
db2se create_srs se_bank -srsId 4000 -srsName new_york1983
-xOffset 0 -yOffset 0 -xScale 1 -yScale 1
-coordsysName NAD_1983_StatePlane_New_York_East_FIPS_3101_Feet
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE
sample_geometries (id INTEGER, spatial_type varchar(18),
geometry ST_GEOMETRY)
INSERT INTO sample_geometries(id, spatial_type, geometry)
VALUES
(1, 'st_point', ST_Point(50, 50, 4000)),
(2, 'st_linestring',
ST_LineString('linestring(200 100, 210 130,
220 140)', 4000)),
(3, 'st_polygon',
ST_Polygon('polygon((110 120, 110 140, 130 140,
130 120, 110 120))',4000)),
(4, 'st_multipolygon',
ST_MultiPolygon('multipolygon(((30 30, 30 40,
35 40, 35 30, 30 30),(35 30, 35 40, 45 40,
45 30, 35 30)))', 4000))
Example 2
SELECT id, spatial_type,
cast(geometry..ST_Buffer(10)..ST_AsText AS varchar(470)) AS buffer_10
FROM sample_geometries
ID SPATIAL_TYPE BUFFER_10
----------- ------------------ ------------------------------------------
1 st_point POLYGON (( 60.00000000 50.00000000,
59.00000000 55.00000000, 54.00000000 59.00000000, 49.00000000
60.00000000, 44.00000000 58.00000000, 41.00000000 53.00000000,
40.00000000 48.00000000,42.00000000 43.00000000, 47.00000000
41.00000000, 52.00000000 40.00000000, 57.00000000 42.00000000,
60.00000000 50.00000000))
2 st_linestring POLYGON (( 230.00000000
140.00000000, 229.00000000 145.00000000, 224.00000000
149.00000000, 219.00000000 150.00000000, 213.00000000 147.00000000,
203.00000000 137.00000000, 201.00000000 133.00000000, 191.00000000
103.00000000, 191.00000000 99.00000000, 192.00000000 95.00000000,
196.00000000 91.00000000, 200.00000000 91.00000000,204.00000000
91.00000000, 209.00000000 97.00000000, 218.00000000 124.00000000,
227.00000000 133.00000000, 230.00000000 140.00000000))
3 st_polygon POLYGON (( 140.00000000 120.00000000,
140.00000000 140.00000000, 139.00000000 145.00000000, 130.00000000
150.00000000, 110.00000000 150.00000000, 105.00000000 149.00000000,
100.00000000 140.00000000,100.00000000 120.00000000, 101.00000000
115.00000000, 110.00000000 110.00000000,130.00000000 110.00000000,
135.00000000 111.00000000, 140.00000000 120.00000000))
4 st_multipolygon POLYGON (( 55.00000000 30.00000000,
55.00000000 40.00000000, 54.00000000 45.00000000, 45.00000000
50.00000000, 30.00000000 50.00000000, 25.00000000 49.00000000,
20.00000000 40.00000000, 20.00000000 30.00000000, 21.00000000
25.00000000, 30.00000000 20.00000000, 45.00000000 20.00000000,
50.00000000 21.00000000, 55.00000000 30.00000000))
Example 3
SELECT id, spatial_type,
cast(ST_AsText(ST_Buffer(geometry, -5)) AS varchar(150))
AS buffer_negative_5
FROM sample_geometries
WHERE id = 3
ID SPATIAL_TYPE BUFFER_NEGATIVE_5
----------- ------------------ --------------------------------------
3 st_polygon POLYGON (( 115.00000000 125.00000000,
125.00000000 125.00000000, 125.00000000 135.00000000, 115.00000000
135.00000000, 115.00000000 125.00000000))
Example 4
SELECT id, spatial_type,
cast(ST_AsText(ST_Buffer(geometry, 10, 'METER')) AS varchar(680))
AS buffer_10_meter
FROM sample_geometries
WHERE id = 3
ID SPATIAL_TYPE BUFFER_10_METER
----------- ------------------ --------------------------------------
3 st_polygon POLYGON (( 163.00000000 120.00000000,
163.00000000 140.00000000, 162.00000000 149.00000000, 159.00000000
157.00000000, 152.00000000 165.00000000, 143.00000000 170.00000000,
130.00000000 173.00000000, 110.00000000 173.00000000, 101.00000000
172.00000000, 92.00000000 167.00000000, 84.00000000 160.00000000,
79.00000000 151.00000000, 77.00000000 140.00000000, 77.00000000
120.00000000, 78.00000000 111.00000000, 83.00000000 102.00000000,
90.00000000 94.00000000, 99.00000000 89.00000000, 110.00000000
87.00000000, 130.00000000 87.00000000, 139.00000000 88.00000000,
147.00000000 91.00000000, 155.00000000 98.00000000, 160.00000000
107.00000000, 163.00000000 120.00000000))