相当于 ArcMap 联合的 PostGIS [英] PostGIS equivalent of ArcMap Union

查看:52
本文介绍了相当于 ArcMap 联合的 PostGIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PostGIS/PostgreSQL 中

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

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

解决方案

这是一个基于

What is the equivalent in PostGIS / PostgreSQL of the "Union" operation in ArcMap?

Say you have two shapefiles with two features each. (PostGIS equivalent: two tables with two rows with polygon geometries)

then the result would be 1 shapefile with 7 features. (PostGIS equivalent: Table with 7 rows with geometries)

I've looked at ST_Intersect, ST_Union and ST_Collect but can't find the right combination. Your help is much appreciated.

解决方案

Here is a working query based on this answer from gis.stackexchange:

Read it from a) to 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

Result:

这篇关于相当于 ArcMap 联合的 PostGIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆