Constructs a polygon from a LineString 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 SRID to assign to the returned polygon. |
Usage notes
ST_Polygondoes not accept MultiLineString inputs. To build a polygon from a MultiLineString, useST_LineMergeto merge it into a single LineString.
To construct a polygon with holes, use ST_MakePolygon instead.
ST_Polygonsupports 3D geometries and preserves the Z coordinate of the input geometry.
Examples
Create a 2D polygon.
SELECT ST_AsEWKT(ST_Polygon(ST_GeomFromText('LINESTRING(1 2,3 4,5 6,1 2)'), 4326));Output:
st_asewkt
--------------------------------------
SRID=4326;POLYGON((1 2,3 4,5 6,1 2))
(1 row)See also
ST_AsEWKT— converts a geometry to EWKT formatST_GeomFromText— constructs a geometry from a WKT stringST_LineMerge— merges a MultiLineString into a single LineStringST_MakePolygon— constructs a polygon with optional interior rings (holes)
该文章对您有帮助吗?