ST_Perimeter function

The ST_Perimeter function takes a surface or multisurface and, optionally, a unit as input parameters and returns the perimeter of the surface or multisurface, that is the length of its boundary, measured in the default or given units.

If the given surface or multisurface is null or is empty, null is returned.

This function can also be called as a method.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_Perimeter(surface ,unit )

Parameters

surface
A value of type ST_Surface, ST_MultiSurface, or one of their subtypes 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 surface is in a projected or geocentric coordinate system, the linear unit associated with this coordinate system is the default.
  • If surface is in a geographic coordinate system, the angular unit associated with this coordinate system is the default.
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

Example 1
This example illustrates the use of the ST_Perimeter function. A spatial reference system with an ID of 4000 is created using a call to db2se, and a polygon is created in that spatial reference system.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse

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
The SAMPLE_POLYS table is created to hold a geometry with a perimeter of 18.

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))', 4000))
Example 2
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 3
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