当前位置:网站首页>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)
边栏推荐
- slurm集群搭建
- Two hundred questions in C language (0 basic continuous update) (1~5)
- 升级到Window11体验
- 解决8080端口被占用问题
- (1) Software testing theory (0 basic understanding of basic knowledge)
- 无胁科技-TVD每日漏洞情报-2022-7-26
- 2022年全国职业技能大赛网络安全竞赛试题B模块自己解析思路(8)
- uboot code analysis 1: find the main line according to the purpose
- Project Notes - Take Notes
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-28
猜你喜欢

Vulnhub靶机--born2root

View the library ldd that the executable depends on

逐步揭示makop.mkp勒索病毒中毒防范恢复解密

CLUSTER DAY03( Ceph概述 、 部署Ceph集群 、 Ceph块存储)

SECURITY DAY04( Prometheus服务器 、 Prometheus被监控端 、 Grafana 、 监控数据库)

CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )

vi display line number in buildroot embedded file system

Solve the problem that port 8080 is occupied

文本三剑客——awk 截取+过滤+统计
![[HTB]渗透Backdoor靶机](/img/fd/61fb3fe8498dec4462ee4156adb806.png)
[HTB]渗透Backdoor靶机
随机推荐
GoAhead Server 环境变量注入(CVE-2021-42342)漏洞复现
C语言两百题(0基础持续更新)(1~5)
(3) Software testing theory (understanding the knowledge of software defects)
解决win10安装portal v13/v15要求反复重启问题。
查看可执行文件依赖的库ldd
ETCD集群故障应急恢复-本地数据可用
无胁科技-TVD每日漏洞情报-2022-7-29
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
China Mobile Communications Group Co., Ltd.: Business Power of Attorney
ramdisk实践1:将根文件系统集成到内核中
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-2
buildroot嵌入式文件系统中vi显示行号
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-1
(二)软件测试理论(*重点用例方法编写)
勒索病毒eking.devos.mkp.makop.lockbit.eight.locked.roger等剖析及中毒文件恢复
ssh中的密码登录和密钥登录
购买专栏请看看说明
Es常用操作和经典case整理
buildroot设置dhcp
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-22