Skip to main content

st_exteriorring function

Applies to: check marked yes Databricks Runtime 17.2 and above

Preview

This feature is in Public Preview.

Returns the exterior ring of the input polygon as a linestring.

Syntax

st_exteriorring ( geoExpr )

Arguments

  • geoExpr: A GEOGRAPHY or GEOMETRY value.

Returns

A value of the same type as geoExpr. The function returns an empty linestring if the input is an empty polygon. Otherwise, the function returns the exterior ring of the polygon as a (closed) linestring. The SRID of the output value is equal to that of the input value.

Notes

The function returns NULL if the input is NULL.

Error conditions

Examples

SQL
-- Example taking an empty 2D polygon GEOMETRY.
> SELECT st_asewkt(st_exteriorring(st_geomfromtext('POLYGON EMPTY')));
LINESTRING EMPTY
-- Example taking an empty 2D polygon GEOMETRY with one empty ring.
> SELECT st_asewkt(st_exteriorring(st_geomfromtext('POLYGON(EMPTY)')));
LINESTRING EMPTY
-- Example taking a 2D polygon GEOMETRY with one non-empty ring.
> SELECT st_asewkt(st_exteriorring(st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))', 3857)));
SRID=3857;LINESTRING(0 0,10 0,0 10,0 0)
-- Example taking a 3DZ polygon GEOGRAPHY with two rings.
> SELECT st_asewkt(st_exteriorring(st_geogfromtext('POLYGON Z ((0 0 -1,10 0 -2,0 10 -3,0 0 -1),(1 1 -5,4 1 -6,1 4 -7,1 1 -5))')));
SRID=4326;LINESTRING Z (0 0 -1,10 0 -2,0 10 -3,0 0 -1)
-- Example taking a NULL input.
> SELECT st_exteriorring(NULL);
NULL