Database Reference
In-Depth Information
chp02.use_area
) AS unioned
) as polygonized;
The ST_Polygonize functionwillcreateasinglemultipolygon,soweneedtoex-
plodethisintomultiplesinglepolygongeometriesifwearetodoanythingusefulwith
it. While we are at it, we might as well do the following within a CREATE TABLE
statement:
CREATE TABLE chp02.use_area_alt AS (
SELECT (ST_Dump(the_geom)).geom AS the_geom
FROM (
SELECT ST_Polygonize(the_geom) AS the_geom
FROM (
SELECT ST_Union(the_geom) AS the_geom
FROM (
SELECT chp02.polygon_to_line(the_geom) AS
the_geom FROM
chp02.use_area
) AS unioned
) as polygonized
) AS exploded
);
Wewillbeperformingspatialqueriesagainstthisgeometry,soweshouldcreatean
index in order to ensure ourquery performs well, as shown in the following query:
CREATE INDEX chp02_use_area_alt_the_geom_gist
ON chp02.use_area_alt
USING gist(the_geom);
Finding center points of resultant polygons
In order to extract the appropriate table information from the original geometry and
applythatbacktoourresultantgeometries,wewillperformapoint-in-polygonquery.
For that, we first need to calculate centroids on the resultant geometry:
Search WWH ::




Custom Search