点坐标生成其他要素类型的转换函数(arcDesktop) |
By 3s4d 发表于 2008-2-10 21:23:00 |
格式转换函数(VBA代码) 主要是针对 文本点数据(经纬度/投影坐标等) 要直接生成线数据或者多边形数据的需求来实现开发的,转换成具有一定形式的文本文本文件,如下列格式(可以被Arcgis Desktop 使用)
polyline
线的编号 线的段数
起点编号 点x 点y
终点编号 点x 点y ...... end 这样的格式
*************************************************
Sub QuoteCommaExport()
Dim DestFile As String Dim FileNum As Integer Dim ColumnCount As Integer Dim RowCount As Integer ' 提示用户指定目标文件名。 DestFile = InputBox("请输入文件位置" & _ Chr(10) & "(并且应该输入完整路径):", _ "Quote-Comma Exporter") ' 获取下一个可用的文件句柄编号。 FileNum = FreeFile() ' 关闭错误检查功能。 On Error Resume Next ' 尝试打开目标文件以供输出。 Open DestFile For Output As #FileNum ' 如果出现错误,则报告错误并结束程序。 If Err <> 0 Then MsgBox "无法打开文件 " & DestFile End End If ' 打开错误检查功能。 On Error GoTo 0 ' 循环选择的每一行。 Print #FileNum, "polyline"; Print #FileNum, For RowCount = 1 To Selection.Rows.Count '打印行数 即廊道编号 Print #FileNum, Selection.Cells(RowCount, _ 1).Text & "0"; '写入空行 Print #FileNum, ' 写入第一列并加空格和零值 回车。 Print #FileNum, "0" & Chr(32) & Selection.Cells(RowCount, _ 3).Text & Selection.Cells(RowCount, _ 4).Text & "0.0" & Chr(32) & "0.0"; Print #FileNum, ' 将当前单元格中的文本写入到文件中,文本用引号括起来。 Print #FileNum, "1" & Chr(32) & Selection.Cells(RowCount, _ 5).Text & Selection.Cells(RowCount, _ 6).Text & "0.0" & Chr(32) & "0.0"; Print #FileNum, ' 检查单元格是否位于最后一列。 'If ColumnCount = Selection.Columns.Count Then ' 如果是,则写入一个空行。 'Print #FileNum, ' Else ' 否则,则写入一个逗号。 'Print #FileNum, ","; 'End If ' 开始 ColumnCount 循环的下一个迭代。 ' 开始 RowCount 循环的下一个迭代。 Next RowCount ' 关闭目标文件。 Print #FileNum, "END" Close #FileNum End Sub
然后就可以根据ArcGIS Desktop中的arctoolboxs工具中的 create features from text 来加载文本数据转换就可以了
转自:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=22767&extra=page%3D11&page=2
|