You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostGIS中使用ST_Intersects关联PolyhedralSurface时报错的解决求助

解决ST_Intersects处理PolyhedralSurface与2D几何体时的"Unknown geometry type"错误

错误原因

你遇到的ERROR: Unknown geometry type: 13 - PolyhedralSurface,是因为PostGIS的ST_Intersects无法直接处理3D多面体表面(PolyhedralSurface)与2D多边形的跨维度相交判断,几何类型不匹配导致函数无法识别操作对象。

解决方案(需保留ST_Intersects)

通过统一两者的几何维度(要么都转为2D,要么都转为3D)即可解决问题,以下提供两种可行方案:

方案1:将3D PolyhedralSurface转为2D几何体

使用ST_2D函数剥离mines表中location字段的Z轴信息,把3D多面体转为2D多边形,再与查询的2D多边形做相交判断:

insert into ucesfur.mining_sites (site_name, mine_id, production_rate, location)
values ('Site A1',
        (select mine_id 
         from ucesfur.mines 
         where st_intersects(ST_2D(location), 
st_geomfromtext('POLYGON((400002 200002, 400008 200002, 400008 200008, 400002 200008, 400002 200002))',27700))),
500.00,
st_geomfromtext('POLYGON((400002 200002, 400008 200002, 400008 200008, 400002 200008, 400002 200002))',27700)
);

方案2:将2D查询多边形转为3D几何体

给查询的多边形添加Z轴坐标(设为0,和创建mines时的基底Z值一致),让它成为3D几何体,与原3D PolyhedralSurface做相交判断:

insert into ucesfur.mining_sites (site_name, mine_id, production_rate, location)
values ('Site A1',
        (select mine_id 
         from ucesfur.mines 
         where st_intersects(location, 
st_geomfromtext('POLYGON((400002 200002 0, 400008 200002 0, 400008 200008 0, 400002 200008 0, 400002 200002 0))',27700))),
500.00,
st_geomfromtext('POLYGON((400002 200002, 400008 200002, 400008 200008, 400002 200008, 400002 200002))',27700)
);

原理说明

两种方案都是通过对齐几何对象的维度,消除ST_Intersects对不同维度/类型几何体的识别障碍,确保函数能正常执行相交逻辑判断,同时满足你"必须使用ST_Intersects"的要求。

内容的提问来源于stack exchange,提问作者relayyyyy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 06:15:06