This topic describes the ST_Polygon function. This function constructs a polygon object by using a LineString object and a spatial reference identifier (SRID).

Syntax

geometry  ST_Polygon(geometry  aLineString , integer  srid);

Parameters

Parameter Description
aLineString The LineString object that you want to specify.
srid The spatial reference identifier (SRID) of the polygon object.

Description

  • This function does not support MultiLineString objects. If you want to construct a polygon object by using a MultiLineString object, you can use the ST_LineMerge function to merge the LineString objects that comprise the MultiLineString object.
  • This function cannot construct a polygon object that contains holes. If you want to construct a polygon object that contains holes, use the ST_MakePolygon function.
  • This function supports 3D objects and does not discard the z-index of the geometry object that is constructed.

Examples

SELECT ST_AsEWKT(ST_Polygon(ST_GeomFromText('LINESTRING(1 2,3 4,5 6,1 2)'),4326));
              st_asewkt
--------------------------------------
 SRID=4326;POLYGON((1 2,3 4,5 6,1 2))
(1 row)