当前位置:网站首页>Arcgis小工具_实现重叠分析
Arcgis小工具_实现重叠分析
2022-08-11 05:33:00 【我是无名的我】
需求:两个矢量文件,当A与B有重叠(包括相交和包含)面积时,赋予B某些A的字段。
要点:用到了arcpy的几何模块。
坑点:
- 写arcgis脚本的编码方式最好为ASCII(因为编码问题,在代码中有中文时必须转换为ASCII,可使用notepad++转换)。
- 中文使用
XX.decode('utf-8')
转换。 - 使用
arcpy.da.UpdateCursor
、arcpy.da.InsertCursor
、arcpy.da.SearchCursor
三个函数时,注意:许多次遍历时,注意重新使用arcpy.da.XXXXXCursor
再次打开数据。
""" Created on Fri Aug 14 17:34:37 2020 @author: zonggongban HGH """
import arcpy
""" 接收脚本输入 """
ds0 = arcpy.GetParameterAsText(0)
ds0 = u'{}'.format(ds0)
fields0 = arcpy.GetParameterAsText(1)
ds1 = arcpy.GetParameterAsText(2)
ds1 = u'{}'.format(ds1)
fields1 = arcpy.GetParameterAsText(3)
with arcpy.da.UpdateCursor(ds0, ['[email protected]', fields0]) as cursor0:
for row0 in cursor0:
temp = ''
with arcpy.da.SearchCursor(ds1, ['[email protected]', fields1]) as cursor1:
for row1 in cursor1:
if row0[0].contains(row1[0]):
temp += row1[1] + '、'.decode('utf-8')
elif row0[0].overlaps(row1[0]):
temp += row1[1] + '、'.decode('utf-8')
else:
pass
row0[1] = temp[0:len(temp)-1]
cursor0.updateRow(row0)
脚本设定:
备注:
- 要素类1、2设定一致,字段1、2设定一致。
- 在spyder里面使用arcpy
import sys arcpy_path = [r'C:\Python27\ArcGIS10.6\Lib\site-packages', r'C:\Program Files (x86)\ArcGIS\Desktop10.6\arcpy', r'C:\Program Files (x86)\ArcGIS\Desktop10.6\bin', r'C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcToolbox\Scripts'] sys.path.extend(arcpy_path)
边栏推荐
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-3
- ansible批量安装zabbix-agent
- SECURITY DAY01 (Monitoring Overview, Zabbix Basics, Zabbix Monitoring Services)
- xx is not recognized as internal or external command
- 勒索病毒eking.devos.mkp.makop.lockbit.eight.locked.roger等剖析及中毒文件恢复
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-25
- CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-28
- SECURITY DAY02( Zabbix报警机制 、 Zabbix进阶操作 、 监控案例)
- Project Notes - Random 2
猜你喜欢
随机推荐
VMware workstation 16 installation and configuration
FusionCompute8.0.0 实验(2)虚拟机创建
(3) Software testing theory (understanding the knowledge of software defects)
FusionCompute8.0.0实验(0)CNA及VRM安装(2280v2)
无胁科技-TVD每日漏洞情报-2022-7-19
Basic use of Slurm
No threat of science and technology - TVD vulnerability information daily - 2022-7-21
vi display line number in buildroot embedded file system
slurm cluster construction
无胁科技-TVD每日漏洞情报-2022-7-29
项目笔记——随记
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-6
无胁科技-TVD每日漏洞情报-2022-7-27
AUTOMATION DAY06( Ansible进阶 、 Ansible Role)
ETCD集群故障应急恢复-从snapshot恢复
CLUSTER DAY03( Ceph概述 、 部署Ceph集群 、 Ceph块存储)
文本三剑客——awk 截取+过滤+统计
购买专栏请看看说明
Project Notes - Random 2
Windos10专业版开启远程桌面协助