将ST_Intersection与三个或更多表一起使用

时间:2019-03-13 22:58:02

标签: gis postgis spatial intersection

我正在尝试与PostGIS实现多表相交,同时保留每种形状的几何图形。

对于任何给定的属性形状,我希望该形状的各个切口被下面各层的不同特征分开。

例如:

480128 | 3Sh3W | Otamatea | MOZ | S | 2 | B' | 5 | P 5 | geom
480128 | 3Sh3W | Turangai| MOZ | L/S | 2 | B' | 5 | P 5 | geom
480128 | 3Sh3W | Makahu | ZOT | L/S | 2 | B' | 5 | P 5 | geom

到目前为止,我使用的SQL是:

CREATE TABLE sd_processed AS 
SELECT 
    A.title_no, 
    B.erosion, 
    C.series, 
    C.domnzsc nzsc,
    C.ps, 
    D.prd_class as prd, 
    E.slope as slope, 
    F.drain_clas as drain,
    G.veg,
    ST_DUMP(ST_INTERSECTION(
        A.geom, 
        ST_INTERSECTION(A.geom,
            ST_INTERSECTION(B.geom, 
                ST_INTERSECTION(C.geom,
                    ST_INTERSECTION(D.geom, 
                        ST_INTERSECTION(E.geom, 
                            ST_INTERSECTION(F.geom, G.geom)
                        )
                    )
                )
            )
        )
    )) geom
FROM
    sd_title A,
    sd_erosion B,
    sd_particle_size C,
    sd_potential_rooting_depth D,
    sd_slope E,
    sd_soil_drainage F,
    sd_vegetation G
WHERE
    ST_INTERSECTS(A.geom, B.geom) = true
    AND ST_INTERSECTS(A.geom, C.geom) = true
    AND ST_INTERSECTS(A.geom, D.geom) = true
    AND ST_INTERSECTS(A.geom, E.geom) = true
    AND ST_INTERSECTS(A.geom, F.geom) = true
    AND ST_INTERSECTS(A.geom, G.geom) = true
    AND ST_INTERSECTS(B.geom, C.geom) = true
    AND ST_INTERSECTS(B.geom, D.geom) = true
    AND ST_INTERSECTS(B.geom, E.geom) = true
    AND ST_INTERSECTS(B.geom, F.geom) = true
    AND ST_INTERSECTS(B.geom, G.geom) = true
    AND ST_INTERSECTS(C.geom, D.geom) = true
    AND ST_INTERSECTS(C.geom, E.geom) = true
    AND ST_INTERSECTS(C.geom, F.geom) = true
    AND ST_INTERSECTS(C.geom, G.geom) = true
    AND ST_INTERSECTS(D.geom, E.geom) = true
    AND ST_INTERSECTS(D.geom, F.geom) = true
    AND ST_INTERSECTS(D.geom, G.geom) = true
    AND ST_INTERSECTS(E.geom, F.geom) = true
    AND ST_INTERSECTS(E.geom, G.geom) = true
    AND ST_INTERSECTS(F.geom, G.geom) = true
LIMIT 1000;

但是,这导致ST_INTERSECTION()在某些行上工作,而所有其他行返回一个空的几何。

有人知道在这里采取另一种方法吗?

0 个答案:

没有答案