当前位置:网站首页>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)
边栏推荐
- Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
- (一)软件测试理论(0基础了解基础知识)
- Es common operations and classical case
- uboot sets the default bootdelay
- ETCD cluster fault emergency recovery - local data is available
- slurm集群搭建
- 无胁科技-TVD每日漏洞情报-2022-8-7
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-19
- 网络安全学习小结--kali基本工具、webshell、代码审计
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-18
猜你喜欢
随机推荐
CLUSTER DAY04(块存储应用案例 、 分布式文件系统 、 对象存储)
windows10安全中心显示“修正未完成”
HPC platform building
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-28
uboot code analysis 1: find the main line according to the purpose
Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
无胁科技-TVD每日漏洞情报-2022-8-4
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-5
无胁科技-TVD每日漏洞情报-2022-7-30
C语言两百题(0基础持续更新)(1~5)
vi display line number in buildroot embedded file system
CLUSTER DAY03 (Ceph overview, the deployment of Ceph CLUSTER, Ceph block storage)
无胁科技-TVD每日漏洞情报-2022-8-5
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-22
buildroot设置dhcp
TCP 三次握手、四次断开
AUTOMATION DAY06 (Ansible Advanced, Ansible Role)
(二)软件测试理论(*重点用例方法编写)
SSL证书部署后,为什么还是显示不安全?
(三)软件测试理论(了解软件的缺陷知识)