Skip to main content

st_makepolygon function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 17.1 and above

Preview

This feature is in Public Preview.

note

This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types

Constructs a polygon GEOMETRY from the input outer boundary and optional array of inner boundaries, represented as closed linestrings.

Syntax

st_makepolygon ( outer[, innerArray] )

Arguments

  • outer: A GEOMETRY value.
  • innerArray: An array of GEOMETRY values.

Returns

A value of type GEOMETRY, representing a polygon.

Any NULL values in the inner boundaries array are ignored.

The SRID value of the output polygon is the common SRID value of the input geometries.

The dimension of the output polygon is the maximum common dimension of the input linestrings.

The function returns NULL if any of the inputs is NULL.

Error conditions

Examples

SQL
-- Returns a polygon constructed from the outer boundary.
> SELECT st_astext(st_makepolygon(st_geomfromtext('LINESTRING(0 0,10 0,10 10,0 10,0 0)')));
POLYGON((0 0,10 0,10 10,0 10,0 0))
-- Returns a polygon constructed from the outer boundary and an inner boundary.
> SELECT st_astext(st_makepolygon(st_geomfromtext('LINESTRING(0 0,10 0,10 10,0 10,0 0)'), array(st_geomfromtext('LINESTRING(1 1,2 1,1 2,1 1)'))));
POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,2 1,1 2,1 1))