基于ArcGIS的三维路网可视化

1. 引言

ArcGIS作为GIS的集大成者,对于三维可视化方面也有集成,参考自:3D 折线 (polyline) 要素—ArcMap | 文档 (arcgis.com),可以使用ArcGIS来构造与显示三维路网

使用ArcGIS创建3D polyline主要有两种方式:

  • 新建 3D 线要素类:定义要素类的几何时选中坐标包括 Z 值复选框。
  • 转换现有的 2D 数据:从高程表面获取高度值或使用现有要素属性

详细信息参考:3D 折线 (polyline) 要素—ArcMap | 文档 (arcgis.com)

此次笔者将高程数据写为2D数据的属性,再使用要素属性将2D polyline转化为3D polyline

2. 数据描述

笔者的数据示例如下所示:

38406174.4883,3151120.24725,332.794756
38406149.819,3151113.57996,336.863586
38400526.1848,3146348.79657,90.0
38400537.386,3146371.63206,109.182556
38406169.3211,3149468.75793,107.071533
38406135.9842,3149417.08638,107.745277

每一行为一个点,字段分别为X,Y,Z

每两个点构成一条线,比如1、2是一条线,3、4是一条线,以此类推

3. 构造二维路网

此处笔者使用Python编写脚本将csv数据转换为二维路网,并将高程写为属性数据z1和z2,并设置投影

代码基于Python3.6构建

使用到的库有:

  • pyshp
  • pyproj(需要2.0以上版本)
from pyproj import CRS
import shapefile 

epsg_num = 4526
data_address = '../data/result/final_map_dem.shp'
dem_csv = '../data/tmp/output/final_map_with_dem.csv'

file = shapefile.Writer(data_address)
# 创建字段
file.field('id', 'N')
file.field('z1', 'F')
file.field('z2', 'F')

polyline = []
with open(dem_csv,'r') as points:
    points = points.readlines()
    i = 0
    while (i < len(points)):
        point1 = points[i].split(',')
        point2 = points[i+1].split(',')
        line = [[float(point1[0]),float(point1[1])],[float(point2[0]),float(point2[1])]]
        polyline.append([line, float(point1[2][:-1]), float(point2[2][:-1])])
        i=i+2

for i, traj in enumerate(polyline):
	file.line([traj[0]])
	file.record(i,traj[1], traj[2])

# 写入数据
file.close()
# 定义投影
crs = CRS.from_epsg(epsg_num)
wkt = crs.to_wkt('WKT1_ESRI')
# 写入投影
f = open(data_address.replace(".shp", ".prj"), 'w') 
f.write(wkt)
f.close()

经过上述脚本,我们就得到了.shp文件

4. 生成三维路网

使用ArcMap,加载刚才生成的.shp文件

image-20220608020353872

点击Feature To 3D By Attribute功能,设置参数即可得到3D路网:

image-20220608020548354

5. 在ArcScene中可视化

在ArcScene中加载刚才生成的三维路网.shp文件,就可以看到生成的三维路网(底图为DEM图片):

动画

另外,我们可以使用DEM数据设置地形:

image-20220608021603485

由于DEM与路网重叠,我们将路网提高40米以展示:

image-20220608021702528

设置一下合理的配色,即可得到一个不错的可视化效果:

动画2

posted @ 2022-06-08 14:38  当时明月在曾照彩云归  阅读(987)  评论(0)    收藏  举报