ST_Perimeter
ST_Perimeter takes a geometry type of polygon or multipolygon, and optionally, a unit as input parameters and returns the perimeter of the polygon or multipolygon. The perimeter is the length of its boundary as measured in the given units.
If the given polygon or multipolygon is null or is empty, null is returned.
Syntax
Parameters
- geometry
- A value of type ST_polygon or ST_Multipolygon for which the perimeter is returned.
- unit
- A VARCHAR(128) value that identifies the units in which the perimeter
is measured. The supported units of measure are listed in the DB2GSE.ST_UNITS_OF_MEASURE
catalog view. If the unit parameter is omitted, the following rules are used to determine the unit in which the perimeter is measured:
- If geometry is in a projected or geocentric coordinate system, the linear unit associated with this coordinate system is used.
- If geometry is in a geographic coordinate system, the angular unit associated with this coordinate system is used.
Restrictions on unit conversions: An error (SQLSTATE 38SU4) is returned if any of the following conditions occur:- The geometry is in an unspecified coordinate system and the unit parameter is specified.
- The geometry is in a projected coordinate system and an angular unit is specified.
- The geometry is in a geographic coordinate system and a linear unit is specified.
Return type
DOUBLE
Examples
The following examples illustrate
the use of the ST_Perimeter function. These examples assume that you
created a SAMPLE_POLYS table to hold a geometry with a perimeter of
18.
SET CURRENT PATH = CURRENT PATH, db2gse
CREATE TABLE sample_polys (id SMALLINT, geometry ST_Polygon)
INSERT INTO sample_polys
VALUES (1, ST_Polygon ('polygon ((0 0, 0 4, 5 4, 5 0, 0 0))', 1))
Example 1
This example lists the ID
and perimeter of the polygon.
SELECT id, ST_Perimeter (geometry) AS PERIMETER
FROM sample_polys
Results:
ID PERIMETER
----------- ------------------------
1 +1.80000000000000E+001
Example 2
This example lists the ID
and perimeter of the polygon with the perimeter measured in meters.
SELECT id, ST_Perimeter (geometry, 'METER') AS PERIMETER_METER
FROM sample_polys
Results:
ID PERIMETER_METER
----------- ------------------------
1 +5.48641097282195E+000
