Why does st_intersection return non-polygons?

南笙酒味 提交于 2021-01-29 06:08:52

问题


I have two polygon layers. I want to run st_intersection on them, to give the result of the areas where they overlap as a new layer. The new layer should contain the attributes from both input layers. I found this image which seems to illustrate my desired end results.

My two input layers are both polygons:

SELECT      st_geometrytype(geom),
            COUNT(*)
FROM        a
GROUP BY    st_geometrytype(geom)
-- Result is 1368 st_polygons

SELECT      st_geometrytype(geom),
            COUNT(*)
FROM        b
GROUP BY    st_geometrytype(geom)
-- Result is 539548 st_polygons

The query I run is as below:

SELECT      a.*,
            b.*,
            st_intersection(a.geom, b.geom) as geom
FROM        a,b
WHERE       st_intersects(a.geom, b.geom)

However in the result I get not just polygons (which I expect), but lines, points, multipolygons and geometry collections. I guess because some of my input polygons share points but not true intersections perhaps?

Grateful for some advice please on how to deal with this, whether my query is correct, anything I can do to improve performance etc. Thanks.

来源:https://stackoverflow.com/questions/63452951/why-does-st-intersection-return-non-polygons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!