首页 > 解决方案 > PostGIS 等效于 ArcMap Union

问题描述

PostGIS / PostgreSQL中 ArcMap中“联合”操作的等价物是什么?

假设您有两个 shapefile,每个具有两个特征。(PostGIS 等效项:两个表,两行,多边形几何)

在此处输入图像描述

那么结果将是 1 个具有 7 个特征的 shapefile。(PostGIS 等效项:具有 7 行几何形状的表格)

在此处输入图像描述

我查看了 ST_Intersect、ST_Union 和 ST_Collect,但找不到正确的组合。非常感谢您的帮助。

标签: postgresqlunionpostgisarcmap

解决方案


这是一个基于gis.stackexchange的答案的工作查询:

从 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

结果:

矩形


推荐阅读