简体   繁体   English

多边形中的点,多个多边形

[英]Points in Polygon, multiple polygons

I have this query working where I populated the prem_council column in my dst db by matching points with polygons in the src. 我有此查询工作,通过将点与src中的多边形匹配来在dst db中填充prem_council列。 But, I could only do it manually by stepping through each district 1-15 manually. 但是,我只能通过手动执行每个分区1-15来手动完成操作。

    UPDATE poursafe.ca_licenses dst
SET prem_council = '1'
FROM ca_la_la_areas_council_dist_2012 src
WHERE EXISTS (
        SELECT *
        FROM public.ca_la_la_areas_council_dist_2012 src
        WHERE ST_Within(dst.geom, src.geom )
        AND district = '1'
        );

I can't figure out how and wonder if you can tell me how I could automate the process so I don't have to do each district manually? 我不知道该怎么做,不知道您是否可以告诉我如何使流程自动化,这样我就不必手动进行每个分区了? The reason I ask is I have several other geographic tables and need to do a similar process. 我问的原因是我还有其他几个地理表格,需要执行类似的过程。 Thanks! 谢谢!

it is blackbox for me without table defination and geometry type of table but if you try to make relation between two tables(ca_licenses and ca_la_la_areas_council_dist_2012), you can simply set district's values to prem_council ; 对于我来说,这是黑盒,没有表定义和表的几何类型,但是如果您尝试在两个表(ca_licenses和ca_la_la_areas_council_dist_2012)之间建立关系,则只需将区的值设置为prem_council即可;

update poursafe.ca_licenses dst
    set prem_council = district 
from ca_la_la_areas_council_dist_2012 src
where st_within(dst.geom,src.geom) and dst.geom&&src.geom --to accelerate query 

Query doesn't solve your problem , pls add table's defination and update conditions to your question. 查询不能解决您的问题,请为您的问题添加表的定义和更新条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM