citysql=‘select * from “市” where 市 like ‘%%铜陵%%’’
citys=gpd.read_postgis(citysql,con=officecon().engineSourcesGis,crs=4326)
print(citys.head())
tsql=‘select * from “全国乡镇边界wgs84” where 所属省 like ‘%%安徽%%’’
towns=gpd.read_postgis(tsql,con=officecon().engineSourcesGis,crs=4326)
antowns=[]
for index,r in citys.iterrows():
towns[‘oa’]=towns[‘geom’].intersection(r[‘geom’]).area
townselect=towns[towns.oa/towns.shape_area>0.5]
# time.sleep(10000)
# townselect=towns[towns[‘geom’].intersects(r[‘geom’])]
如果使用.intersects或者within会存在不相干或遗漏弱相关的点,通过面积的计算通过相交面积与参照需要匹配的图像关系intersection的交叉区域并计算面积比例,可以更加准确的筛选相关元素。