ST_Polygon

更新时间:
复制 MD 格式

Creates a polygon from a LineString and assigns it a spatial reference identifier (SRID).

Syntax

geometry ST_Polygon(geometry aLineString, integer srid)

Parameters

ParameterDescription
aLineStringThe closed LineString to build the polygon from.
sridThe SRID to assign to the resulting polygon.

Description

ST_Polygon returns a polygon built from the given LineString and sets its spatial reference system from the srid. It supports 3D geometries and preserves the z-index of the input.

  • MultiLineString is not accepted. Use ST_LineMerge to merge its components into a single LineString.

  • Polygons with holes are not supported. To create a polygon with holes, use ST_MakePolygon.

Examples

Return EWKT output with SRID prefix.

SELECT ST_AsEWKT(ST_Polygon(ST_GeomFromText('LINESTRING(1 2,3 4,5 6,1 2)'), 4326));

Output:

SRID=4326;POLYGON((1 2,3 4,5 6,1 2))

What's next

  • ST_MakePolygon: Build polygons with holes or without an SRID assignment.