Excel和WPS表格下CASS格式测量地形文件点按距离过滤抽稀

2024-01-25 21:20

本文主要是介绍Excel和WPS表格下CASS格式测量地形文件点按距离过滤抽稀,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文件名:CASS格式地形文件点抽稀(Excel).rar Excel下的VBA程序,在WPS下也可以使用,打开此表格后点击表中按钮,选择CASS格式测量地形点文件,指定抽稀间距即可按距离进行点抽稀过滤。表格见下载中心。
在这里插入图片描述

Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongFunction Distance(Sx As Double, Sy As Double, Ex As Double, Ey As Double, Precision As Integer) As Double
Dim DltX As Double, DltY As Double
DltX = Ex - Sx
DltY = Ey - Sy
Distance = Round(Sqr(DltX * DltX + DltY * DltY), Precision)
End FunctionSub filter()Dim Dia1 As Object, Strr As String, PPath As StringDim filterDist As Integer '抽稀距离Dim Datums As VariantDim RowIndex As LongDim rIndex As Long, rIndex2 As Long, xa As Double, ya As Double, xb As Double, yb As DoubleRowIndex = 1filterDist = Sheet1.Cells(1, 6) '抽稀距离If filterDist = 0 Then filterDist = 2'Sheet1.Cells(1, 7) = "←F1单元格设置抽稀距离"'Sheet1.Cells(2, 7) = "(C)中国电建一二·五联合体测量队"'Sheet1.Cells(3, 7) = "雅砻江两河口水电站大坝工程"'Sheet1.Cells(4, 7) = "覃东 cehui@139.com"Sheet1.Range("A1:E10000").ClearContentsSet Dia1 = Application.FileDialog(msoFileDialogFilePicker)Dia1.Title = "版权所有(C) 中国电建一二·五联合体  覃东 QQ:61902475 Email:cehui@139.com V20160225"With Dia1.AllowMultiSelect = False '限制只能同时选择一个文件.Filters.Clear.Filters.Add "南方CASS格式", "*.dat", 1 '限制显示的文件类型.ShowFor Each vrtSelectedItem In .SelectedItemsPPath = vrtSelectedItemNextEnd WithIf Trim(PPath) <> "" ThenOpen PPath For Input As #1Do While Not EOF(1)Line Input #1, StrrIf Trim(Strr) <> "" ThenDatums = Split(Strr, ",")If UBound(Datums) = 4 ThenSheet1.Cells(RowIndex, 1) = RowIndexSheet1.Cells(RowIndex, 2) = ""Sheet1.Cells(RowIndex, 3) = Datums(2)Sheet1.Cells(RowIndex, 4) = Datums(3)Sheet1.Cells(RowIndex, 5) = Datums(4)End IfEnd IfRowIndex = RowIndex + 1LoopClose #1End If'点抽稀rIndex = 1rIndex2 = rIndex + 1
Do While Sheet1.Cells(rIndex, 1).Text <> ""If Trim(Sheet1.Cells(rIndex2, 2)) = "" Thenxa = Sheet1.Cells(rIndex, 3)ya = Sheet1.Cells(rIndex, 4)rIndex2 = rIndex + 1Do While Sheet1.Cells(rIndex2, 1).Text <> ""If (Abs(Sheet1.Cells(rIndex2, 3).Text - xa) < filterDist And Abs(Sheet1.Cells(rIndex2, 4).Text - ya) < filterDist) ThenIf Distance(xa, ya, Sheet1.Cells(rIndex2, 3).Text, Sheet1.Cells(rIndex2, 4).Text, 3) < filterDist And Trim(Sheet1.Cells(rIndex, 2)) = "" And Trim(Sheet1.Cells(rIndex2, 2)) = "" ThenSheet1.Cells(rIndex2, 2) = "T"End IfEnd IfrIndex2 = rIndex2 + 1LoopEnd IfrIndex = rIndex + 1
LoopIf Trim(PPath) <> "" ThenrIndex = 1RowIndex = 1Open Left(PPath, InStr(UCase(PPath), ".DAT") - 1) & "-抽稀(" & filterDist & "m)-" & Replace(Format(Date, "yyyy-mm-dd"), "-", "") & "-" & Replace(Time, ":", "") & ".dat" For Output As #2Do While Trim(Sheet1.Cells(rIndex, 1)) <> ""'Sheet1.Cells(5, 7) = rIndex & ":" & RowIndexIf Trim(Sheet1.Cells(rIndex, 2)) = "" ThenPrint #2, RowIndex & ",," & Format(Sheet1.Cells(rIndex, 3), "0.000") & "," & Format(Sheet1.Cells(rIndex, 4), "0.000") & "," & Format(Sheet1.Cells(rIndex, 5), "0.000")RowIndex = RowIndex + 1End IfrIndex = rIndex + 1LoopClose #2End IfSheet1.Range("B1:B10000").ClearContentsEnd Sub

在表格中添加一个按钮

在这里插入图片描述
对于删除重合地形点同样有用,只要将过滤间距设为一个很小的值如0.1即可。

这篇关于Excel和WPS表格下CASS格式测量地形文件点按距离过滤抽稀的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/644645

相关文章

Python将博客内容html导出为Markdown格式

《Python将博客内容html导出为Markdown格式》Python将博客内容html导出为Markdown格式,通过博客url地址抓取文章,分析并提取出文章标题和内容,将内容构建成html,再转... 目录一、为什么要搞?二、准备如何搞?三、说搞咱就搞!抓取文章提取内容构建html转存markdown

SpringIntegration消息路由之Router的条件路由与过滤功能

《SpringIntegration消息路由之Router的条件路由与过滤功能》本文详细介绍了Router的基础概念、条件路由实现、基于消息头的路由、动态路由与路由表、消息过滤与选择性路由以及错误处理... 目录引言一、Router基础概念二、条件路由实现三、基于消息头的路由四、动态路由与路由表五、消息过滤

java中使用POI生成Excel并导出过程

《java中使用POI生成Excel并导出过程》:本文主要介绍java中使用POI生成Excel并导出过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录需求说明及实现方式需求完成通用代码版本1版本2结果展示type参数为atype参数为b总结注:本文章中代码均为

利用Python开发Markdown表格结构转换为Excel工具

《利用Python开发Markdown表格结构转换为Excel工具》在数据管理和文档编写过程中,我们经常使用Markdown来记录表格数据,但它没有Excel使用方便,所以本文将使用Python编写一... 目录1.完整代码2. 项目概述3. 代码解析3.1 依赖库3.2 GUI 设计3.3 解析 Mark

如何自定义Nginx JSON日志格式配置

《如何自定义NginxJSON日志格式配置》Nginx作为最流行的Web服务器之一,其灵活的日志配置能力允许我们根据需求定制日志格式,本文将详细介绍如何配置Nginx以JSON格式记录访问日志,这种... 目录前言为什么选择jsON格式日志?配置步骤详解1. 安装Nginx服务2. 自定义JSON日志格式各

python dict转换成json格式的实现

《pythondict转换成json格式的实现》本文主要介绍了pythondict转换成json格式的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下... 一开始你变成字典格式data = [ { 'a' : 1, 'b' : 2, 'c编程' : 3,

java streamfilter list 过滤的实现

《javastreamfilterlist过滤的实现》JavaStreamAPI中的filter方法是过滤List集合中元素的一个强大工具,可以轻松地根据自定义条件筛选出符合要求的元素,本文就来... 目录1. 创建一个示例List2. 使用Stream的filter方法进行过滤3. 自定义过滤条件1. 定

Redis如何实现刷票过滤

《Redis如何实现刷票过滤》:本文主要介绍Redis如何实现刷票过滤问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录引言一、概述二、技术选型三、搭建开发环境四、使用Redis存储数据四、使用SpringBoot开发应用五、 实现同一IP每天刷票不得超过次数六

Java利用poi实现word表格转excel

《Java利用poi实现word表格转excel》这篇文章主要为大家详细介绍了Java如何利用poi实现word表格转excel,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、每行对象类需要针对不同的表格进行对应的创建。package org.example.wordToEx

利用Python实现添加或读取Excel公式

《利用Python实现添加或读取Excel公式》Excel公式是数据处理的核心工具,从简单的加减运算到复杂的逻辑判断,掌握基础语法是高效工作的起点,下面我们就来看看如何使用Python进行Excel公... 目录python Excel 库安装Python 在 Excel 中添加公式/函数Python 读取