python實現(xiàn)DEM數(shù)據(jù)的陰影生成的方法
更新時間:2019年07月23日 14:26:28 作者:林木聲
這篇文章主要介紹了python實現(xiàn)DEM數(shù)據(jù)的陰影生成的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
相關(guān)的依賴庫在我的github網(wǎng)站上
首先貼出代碼:
import solar from gradient import * from shadows import * import numpy as np import matplotlib.pyplot as plt # plt 用于顯示圖片 import matplotlib.image as mpimg # mpimg 用于讀取圖片 # dem import srtm if __name__ == '__main__': ''' # 另一種從網(wǎng)上直接下載DEM數(shù)據(jù) geo_elevation_data = srtm.get_data() image = geo_elevation_data.get_image((500, 500), (45, 46), (13, 14), 300) # the image s a standard PIL object, you can save or show it: image.show() image = np.asarray(image) print(image.shape) ''' # 讀入高程信息 filename = 'dempyrenees.asc' dem = np.loadtxt(filename,skiprows=6,delimiter=' ') # 高程信息的維度 # print(dem) print(dem.shape) # 定義一個光線向量 # 第一個表示和豎直方向的夾角,第二個表示由東向西照射 sv = normal_vector(45, 270) # 生成陰影 shadow = project_shadows(dem=dem,sun_vector=sv,dx=30) print(shadow[1,:]) print(shadow.shape) # 顯示dem和shadow圖像 plt.figure() plt.subplot(1,2,1) plt.imshow(dem,cmap='gray') # 顯示灰度圖像 plt.axis('off') # 不顯示坐標軸 plt.subplot(1,2,2) plt.imshow(shadow,cmap='gray') plt.axis('off') plt.show()
生成的結(jié)果如下:左邊是DEM數(shù)據(jù),右邊是shadow
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python中的不可變數(shù)據(jù)類型與可變數(shù)據(jù)類型詳解
探尋python的數(shù)據(jù)類型是否可變,也可以更好的理解python對內(nèi)存的使用情況,下面這篇文章主要給大家介紹了關(guān)于python中不可變數(shù)據(jù)類型與可變數(shù)據(jù)類型的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下2018-09-09Python 實現(xiàn)網(wǎng)課實時監(jiān)控自動簽到、打卡功能
這篇文章主要介紹了Python實現(xiàn)網(wǎng)課實時監(jiān)控自動簽到,打卡功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03Pytorch統(tǒng)計參數(shù)網(wǎng)絡(luò)參數(shù)數(shù)量方式
這篇文章主要介紹了Pytorch統(tǒng)計參數(shù)網(wǎng)絡(luò)參數(shù)數(shù)量方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02使用Python實現(xiàn)Excel表格轉(zhuǎn)圖片
在數(shù)據(jù)處理與信息分享過程中,Excel表格作為一種強大的數(shù)據(jù)管理工具被廣泛應(yīng)用,這篇文章主要為大家詳細介紹了如何使用Python將Excel表格轉(zhuǎn)換為圖片,需要的可以參考下2024-04-04