Database Reference
In-Depth Information
CREATE OR REPLACE FUNCTION
chp04.polygonize_to_multi (geometry) RETURNS
geometry AS $$
Forreadability,wewillusea WITH statementtoconstructtheseriesoftransforma-
tions of geometry. First, we will polygonize:
WITH polygonized AS (
SELECT ST_Polygonize($1) AS the_geom
),
Then, we will dump:
dumped AS (
SELECT (ST_Dump(the_geom)).geom AS the_geom
FROM
polygonized
)
Now, we can collect and construct a multipolygon from our result:
SELECT ST_Multi(ST_Collect(the_geom)) FROM
dumped
;
Put together into a single function:
CREATE OR REPLACE FUNCTION
chp04.polygonize_to_multi (geometry) RETURNS
geometry AS $$
WITH polygonized AS (
SELECT ST_Polygonize($1) AS the_geom
),
dumped AS (
Search WWH ::




Custom Search