python实现dem输出三维模型_python DEM数据可视化
我們?cè)谶M(jìn)行地形擬合,或者進(jìn)行地形分析的時(shí)候,嘗嘗需要將DEM數(shù)據(jù)可視化,來于其他數(shù)據(jù)進(jìn)行比較。下面是pyrhon DEM數(shù)據(jù)可視化代碼
if __name__ == '__main__':
filePath = u"D:/test/fang" # 輸入你的dem數(shù)據(jù)
dataset = gdal.Open(filePath)
adfGeoTransform = dataset.GetGeoTransform()
band = dataset.GetRasterBand(1) # 用gdal去讀寫你的數(shù)據(jù),當(dāng)然dem只有一個(gè)波段
nrows = dataset.RasterXSize
ncols = dataset.RasterYSize # 這兩個(gè)行就是讀取數(shù)據(jù)的行列數(shù)
Xmin = adfGeoTransform[0] # 你的數(shù)據(jù)的平面四至
Ymin = adfGeoTransform[3]
Xmax = adfGeoTransform[0] + nrows * adfGeoTransform[1] + ncols * adfGeoTransform[2]
Ymax = adfGeoTransform[3] + nrows * adfGeoTransform[4] + ncols * adfGeoTransform[5]
x = np.linspace(Xmin, Xmax, ncols)
y = np.linspace(Ymin, Ymax, nrows)
X, Y = np.meshgrid(x, y)
Z = band.ReadAsArray(0, 0, nrows, ncols)
region = np.s_[10:400, 10:400]
X, Y, Z = X[region], Y[region], Z[region]
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'), figsize=(12, 10))
ls = LightSource(270, 20)
rgb = ls.shade(Z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=rgb,
linewidth=0, antialiased=False, shade=False)
plt.show()
總結(jié)
以上是生活随笔為你收集整理的python实现dem输出三维模型_python DEM数据可视化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: semantic ui中文文档_Vuet
- 下一篇: java接口测试工具_【分享】接口工具对