ST_BuildArea
Name
ST_BuildArea — Creates a polygonal geometry formed by the linework of a geometry.
Synopsis
geometry
ST_BuildArea
(
geometry
geom
)
;
Description
Creates an areal geometry formed by the constituent linework of the input geometry. The input can be a LineString, MultiLineString, Polygon, MultiPolygon or a GeometryCollection. The result is a Polygon or MultiPolygon, depending on input. If the input linework does not form polygons, NULL is returned.
Unlike ST_MakePolygon , this function accepts rings formed by multiple lines, and can form any number of polygons.
This function converts inner rings into holes. To turn inner rings into polygons as well, use ST_Polygonize .
Input linework must be correctly noded for this function to work properly. ST_Node can be used to node lines. If the input linework crosses, this function will produce invalid polygons. ST_MakeValid can be used to ensure the output is valid. |
Availability: 1.1.0
Examples
|
|
WITH data(geom) AS (VALUES ('LINESTRING (180 40, 30 20, 20 90)'::geometry) ,('LINESTRING (180 40, 160 160)'::geometry) ,('LINESTRING (160 160, 80 190, 80 120, 20 90)'::geometry) ,('LINESTRING (80 60, 120 130, 150 80)'::geometry) ,('LINESTRING (80 60, 150 80)'::geometry) ) SELECT ST_AsText( ST_BuildArea( ST_Collect( geom ))) FROM data; ------------------------------------------------------------------------------------------ POLYGON((180 40,30 20,20 90,80 120,80 190,160 160,180 40),(150 80,120 130,80 60,150 80))
SELECT ST_BuildArea(ST_Collect(inring,outring)) FROM (SELECT ST_Buffer('POINT(100 90)', 25) As inring, ST_Buffer('POINT(100 90)', 50) As outring) As t;
See Also
ST_Collect , ST_MakePolygon , ST_MakeValid , ST_Node , ST_Polygonize , ST_BdPolyFromText , ST_BdMPolyFromText (wrappers to this function with standard OGC interface)