postgre 的ST_Intersection 求面的交集

一开始是给了一坨 面的数据

 

需要将面按照街镇 进行分割

 

我想的是改库表  对geometry数据进行处理  

 

后面发现了st_intersection 这个函数  求两个面的交集  

就不用对表进行处理了  只要sql查询就可以了

 

大概sql

select  province_name, city_name, county_name, hazard_class,  color, ST_Intersection(geom, (select geom from nanhaiqu_polygon where name = '西城区')) as geom from dw_p_10_440605_01

where st_intersects(geom, (select geom from nanhaiqu_polygon where name = '西城区')) != 'f'

sql的大概意思是 找给一个北京市的geom数据  和 西城区的geom   找出北京市那张表中位于西城区 且不为空 的数据 

 

posted @ 2023-02-15 15:05  霸王龙168  阅读(292)  评论(0)    收藏  举报