主要想实现两条直线(其中一个线shp是固定的,另一个线shp是多个)之间交点的批量处理,并对结果进行整合,方便后续加载数据和增加经纬度坐标信息。

1 . 利用arcpy 中Intersect_analysis函数实现两直线相交功能,具体代码:
输入数据:
smallshape 为需要进行相交处理的多个线shp;
region 为某个固定的线shp.
目的:将smallshape 中每个线shp与region 进行intersect处理,得到交点shp.

import arcpy,os,datetimefrom arcpy.sa import *import pandas as pdimport refrom arcpy import envpath = r"存放需要处理的shp文件路径"arcpy.env.workspace = patharcpy.env.overwriteOutput = Trueprint("strart")smallshapes  = [f for f in arcpy.ListFeatureClasses() if f.split('.')[0].isdigit()]#List a:print(smallshapes)#infeature = ["big.shp", "small1.shp"]join_attributes = "ALL"#cluster_tolerance = "-1 Unknown"output_type = "POINT"region = r"固定的线shp存放路径" #一个固定的shpi = 0for smallshape in smallshapes:#outfeature = r"输出文件路径" + "{0}.shp".format(i)outfeature = r"输出文件路径名称\intersect_" + str(i) #该程序输出路径命名为intersect_1,intersect_2,如果有其它要求,可以修改代码。print(smallshape)arcpy.Intersect_analysis([smallshape, region], outfeature, join_attributes, "", output_type)i+=1print("end")

参考资料:
Using ArcPy with Intersect and loop:https://gis.stackexchange.com/questions/358430/using-arcpy-with-intersect-and-loop

ListFeatureClasses:https://desktop.arcgis.com/zh-cn/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm

利用Intersect_analysis进行分区统计:https://zhuanlan.zhihu.com/p/61445743

相交 (分析):https://pro.arcgis.com/zh-cn/pro-app/latest/tool-reference/analysis/intersect.htm

2 . 将上面的结果整合merge成一个shp
注意这个步骤,需要控制输入点shp的个数,如果数量超出设定的范围,就会报错:

但是没有找到更好的方法,只能暂时分批次整合(每次小于1000进行操作)。

具体代码:

import arcpy,osout_path =r"整合后文件路径" #整合后的文件路径arcpy.env.workspace = r"需要整合的文件路径" #需要整合的shp路径shplist = arcpy.ListFeatureClasses('*.shp')print(shplist)arcpy.Merge_management(shplist,os.path.join(out_path,'Merged_intersection.shp'))print("done")

参考资料:
Simple Merge of Shapefiles in a single folder:https://community.esri.com/t5/python-questions/simple-merge-of-shapefiles-in-a-single-folder/td-p/337113

arcpy批量合并shp:https://blog.csdn.net/imxiezy/article/details/88605946

arcgis merge:https://desktop.arcgis.com/zh-cn/arcmap/10.3/tools/data-management-toolbox/merge.htm

最新文章

  1. [Silverlight入门系列]实现局部元素全屏(Element部分全屏)
  2. git bash here创建项目无法选择m_你应该知道的10个Git命令
  3. 新思路保障网络安全 基于平台的网络安全架构体系
  4. 【Android】Activity的四种launchMode
  5. 关于C++的extern关键字
  6. centos7 安装 node.js 运行环境、卸载
  7. datetime的文本时间处理
  8. 计算机专业的swot分析图,计算机专业学生个人SWOT分析案例
  9. Win10搭建gym运行atari游戏pong
  10. 双系统时间不一致解决方案
  11. ctf解题--算术题
  12. 群论:Burnside引理与Polya定理
  13. 解决小程序onReachBottom在同屏只能触发一次的问题
  14. 500行C++代码实现软件渲染器 - 0.引言
  15. C#全自动多线程上位机源码编程
  16. 创业融资的步骤和见解
  17. 工业计算机发展历史,石油工业与计算机技术发展史
  18. Position为absolute的div或dropdown menu在设置了overflow的div中显示不完全(cropped)
  19. 华南主板超频设置图解_超频后电脑开不开机了怎么办?
  20. 好家园房产中介网后台管理

热门文章

  1. python 数据 模块 好用_Python最被低估的库,用好了效率提升10倍!
  2. k8s部署nexus3
  3. nacos加载多配置集
  4. 5e的训练模式全是英文_四块GPU即可训练BigGAN:「官方版」PyTorch实现出炉
  5. myeclipse java设置_【使用指南】MyEclipse部署配置(多图)
  6. Python根据mask在原图上进行标记
  7. Javascript:利用闭包实现高级排他
  8. linux设置开机自启动的方式总结
  9. python_numpy_矩阵乘法multiply()、dot()、 matmul()、 * 、 @ 辨析
  10. 眼底图像血管增强与分割--(1)匹配滤波算法原理及实现