ST_PolygonFromText¶
Constructs a Polygon from Well-Known Text (WKT), erroring if the input is not a Polygon.
Usage¶
geometry ST_PolygonFromText(wkt: string)
geometry ST_PolygonFromText(wkt: string, srid: crs)
Arguments¶
- wkt (string)
- srid (crs)
Description¶
Parses a WKT string and returns a geometry. Raises an error if the WKT does not represent a Polygon.
Examples¶
SELECT ST_PolygonFromText('POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))');
┌─────────────────────────────────────────────────────────────────┐
│ st_polygonfromtext(Utf8("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))")) │
│ geometry │
╞═════════════════════════════════════════════════════════════════╡
│ POLYGON((0 0,4 0,4 4,0 4,0 0)) │
└─────────────────────────────────────────────────────────────────┘
With an SRID or CRS:
SELECT ST_PolygonFromText('POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))', 4326);
┌─────────────────────────────────────────────────────────────────────────────┐
│ st_polygonfromtext(Utf8("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))"),Int64(4326)) │
│ geometry │
╞═════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 0,4 0,4 4,0 4,0 0)) │
└─────────────────────────────────────────────────────────────────────────────┘