PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

PostGIS equivalente do ArcMap Union


Aqui está uma consulta de trabalho com base nesta resposta de gis.stackexchange :

Leia de a) a d):
-- d) Extract the path number and the geom from the geometry dump
SELECT
  (dump).path[1] id,
  (dump).geom
FROM
(
  -- c) Polygonize the unioned rings (returns a GEOMETRYCOLLECTION)
  --    Dump them to return individual geometries
  SELECT
    ST_Dump(ST_Polygonize(geom)) dump
  FROM
  (
    -- b) Union all rings in one big geometry
    SELECT
      ST_Union(geom) geom
    FROM
    (
      -- a) First get the exterior ring from all geoms
      SELECT
        ST_ExteriorRing(geom) geom
      FROM
        rectangles
    ) a
  ) b
) c

Resultado: