Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Databricks Runtime 17.1 and above
Important
This feature is in Public Preview.
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
: AGEOMETRY
value.innerArray
: An array ofGEOMETRY
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
- If any of the input geometries is not linestring, the function returns ST_INVALID_ARGUMENT_TYPE.
- If the input geometries do not have the same SRID value, the function returns ST_DIFFERENT_SRID_VALUES.
- If the outer boundary is an empty linestring, the array of inner boundaries is expected to be an empty array. Otherwise, the function returns ST_INVALID_ARGUMENT.
Examples
-- 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))