Name

ST_BuildArea — Creates a surface geometry from the lines of the input geometries.

Synopsis

geometry ST_BuildArea(bytea Geometry);

Alias

BuildArea

Description

Creates a surface geometry from the lines of the input geometries.

[Note]

This method supports GeometryCollections

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

CREATE TABLE "lines"(id serial PRIMARY KEY);
SELECT AddGeometryColumn ('lines','GEOM',25830,'LINESTRING',2);

INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (1 1, 1 4, 1 7)'));
INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (1 7, 3 7, 6 7)'));
INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (6 7, 6 3, 6 1)'));
INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (1 1, 4 1, 6 1)'));

--H2
SELECT asewkt(ST_BuildArea(ST_CollectAgg("lines"."GEOM"))) as polygon from "lines";

--PostgreSQL
SELECT asewkt(ST_BuildArea(ST_Collect("lines"."GEOM"))) as polygon from "lines";

SELECT DropGeometryTable ('lines');

--Result
                              polygon
--------------------------------------------------------------------
 SRID=25830;POLYGON ((1 7, 3 7, 6 7, 6 3, 6 1, 4 1, 1 1, 1 4, 1 7))
(1 row)
A
ST_BuildArea(A)
SELECT ST_asewkt(ST_BuildArea(ST_GeomfromText('MULTILINESTRING ((1 1, 1 5, 6 5, 6 1, 1 1), 
  (3 7, 3 3, 8 3, 8 8, 3 8, 3 7))')));
--Result
MULTIPOLYGON (((3 7, 3 8, 8 8, 8 3, 6 3, 6 5, 3 5, 3 7)), ((3 5, 3 3, 6 3, 6 1, 1 1, 1 5, 3 5)))
A
ST_BuildArea(A)

Related functions

ST_Collect,ST_Polygonize