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 SQL
Databricks Runtime 17.1 and above
Important
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 value from the input outer boundary and optional array of inner boundaries, represented as closed linestrings.
Syntax
st_makepolygon ( outer[, innerArray] )
Arguments
outer: AGEOMETRYvalue.innerArray: An array ofGEOMETRYvalues.
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.INVALID_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.EMPTY_OUTER_BOUNDARY.
- If the outer boundary has less than four vertices, the function returns ST_INVALID_ARGUMENT.TOO_FEW_VERTICES_IN_OUTER_BOUNDARY.
- If the outer boundary is not closed, the function returns ST_INVALID_ARGUMENT.OUTER_BOUNDARY_NOT_CLOSED.
- If any of the inner boundaries has less than four vertices, the function returns ST_INVALID_ARGUMENT.TOO_FEW_VERTICES_IN_INNER_BOUNDARY.
- If any of the inner boundaries is not closed, the function returns ST_INVALID_ARGUMENT.INNER_BOUNDARY_NOT_CLOSED.
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))