1 數據預處理
(1)數據提取
我們可以選取2018年5月初華東地區MODIS中的MOD11A2和MOD13A2的16天合成LST和NDVI產品數據,下載地址:MODIS數據下載
網站下載數據需要註冊,在此聲明,下載數據不需要“科學上網”,但註冊需要谷歌Gmail郵箱,註冊Gmail郵箱需要“科學上網”。以下是我們下載數據,數據下載中可以通過Python腳本的方法對數據進行批量下載,由於我們只需要少量數據,不必批量下載,所以在此不加贅述。以下是我們的原始數據在ENVI中的顯示:
由於MODIS產品數據下載之後不能直接使用,因此需要對數據進行預處理。
首先EarthData網站上獲取的數據爲*.hdf格式,此時不能直接有ENVI軟件直接處理,需要批量提取,這時就要用到NASA提供的MODIS Reprojection Tool,此工具雖不能實現全自動的批量提取,但是可以實現按月進行數據的提取及拼接,以下是利用MRT軟件提取數據參數設置:
NDVI產品數據也用以上同樣的方法輸入MOD11A2數據提取,輸出LST和NDVI數據。
(2)數據復原
此時數據依然不能直接使用,由於LST數據是16bit的,其顯示範圍是0-65535,有效範圍則是7500-65535,需要乘以0.02才能得到開爾文溫度。而NDVI數據爲了減少儲存空間,也是正常值的10000倍,所以應該給其乘以0.0001得到正常值,以上都是利用EMVI的Bandmath工具進行,在此不加贅述。
(3)數據裁剪
由於涉及範圍比較廣,所以我們對數據進行裁剪處理,裁取山東地區的一小部分作爲分析樣本進行數據迴歸分析與相關性分析,具體範圍如下專題圖:
2 代碼與步驟
Pro Regress_ndvi_lst
;input the image
fn_ndvi=**dialog_pickfile**(title='Please Input the NDVI Image:')
fn_lst=**dialog_pickfile**(title='Please Input the LST Image:')
;read the image
ndvi_img=**read_image**(fn_ndvi)
lst_img=**read_image**(fn_lst)
;get the size of image
sz_ndvi=**size**(ndvi_img)
;get the image's numbers of columns and rows
ndvi_columns=sz_ndvi[**1**] & ndvi_rows=sz_ndvi[**2**]
;get the size of image
sz_lst=**size**(lst_img)
;get the image's numbers of columns and rows
lst_columns=sz_lst[**1**] & lst_rows=sz_lst[**2**]
;samples
random_c=**randomu**(seed,ndvi_columns)
random_r=**randomu**(seed,ndvi_rows)
sort_c=**sort**(random_c)
sort_r=**sort**(random_r)
ndvi_samples=ndvi_img[sort_c[**0**:**10**],*]
lst_samples=lst_img[sort_c[**0**:**10**],*]
ndvi_get=**reform**(ndvi_samples,**11***ndvi_rows, **1**)
lst_get=**reform**(lst_samples,**11***ndvi_rows, **1**)
ref_ndvi=**reform**(ndvi_get)
ref_lst=**reform**(lst_get)
;ref_ndvi1=reform(ndvi_img,ndvi_columns*ndvi_rows,1)
;ref_lst1=reform(lst_img,lst_columns*lst_rows,1)
;ref_ndvi=ref_ndvi1[0:100]
;ref_lst=ref_lst1[0:100]
;regress analysis
fit_ndvi_lst=**regress**(ref_ndvi,ref_lst,const=b,correlation=r,yfit=lst_estimated)
;plot points picture
p1=**plot**(ref_ndvi,ref_lst,xtitle='NDVI',ytitle='LST(K)',dimensions=[**600**,**400**], symbol=**1**,color='red',sym_size=**1.0**,linestyle=**6**,$
title='The Regress of NDVI & LST',window_title='NDVI & LST',$
xrange=[**0**,**1**],yrange=[**290**,**310**])
;set the range of x and y axis
x=ref_ndvi
y=fit_ndvi_lst[**0**]*x+b
fit=**plot**(x,y,linestyle=**1**,color='blue',thick=**2**,/current,/overplot)
p2=**plot**([**0**,**1**],[**290**,**310**],linestyle=**6**,/current,/overplot)
str_equation='Y='+**string**(fit_ndvi_lst[**0**],format='(f6.2)')+'*X+'+**string**(b,format='(f6.2)')
str_correlation='R='+**string**(r,format='(f5.2)')
t1=**text**(**0.20**,**0.80**,str_equation,font_size=**12**,target=p1)
t2=**text**(**0.20**,**0.75**,str_correlation,font_size=**12**,target=p1)
;o_fn='Scatter_ndvi_lst.emf'
;p1.save,o_fn,border=40
;p2.save,o_fn,border=40
;**********
;plot points picture
p3=**plot**(ref_lst,lst_estimated,xtitle='LST(K)',ytitle='LST-Estimated(K)',dimensions=[**600**,**400**],$
symbol=**24**,color='red',sym_size=**1.0**,title='LST & LST-Estimated',$
window_title='Cal_LST_Linear',linestyle=**6**,xrange=[**290**,**310**],yrange=[**290**,**310**])
;set the range of x and y axis
p4=**plot**([**290**,**310**],[**290**,**310**],thick=**2**,color='blue',/current,/overplot)
MAE=**mean**(**abs**(ref_lst-lst_estimated))
RMSE=**sqrt**(**mean**((ref_lst-lst_estimated)^**2**))
str_MAE='MAE='+**string**(MAE,format='(f5.2)')
str_RMSE='RMSE='+**string**(RMSE,format='(f5.2)')
t3=**text**(**0.20**,**0.80**,str_MAE,font_size=**12**,target=p3)
t4=**text**(**0.20**,**0.75**,str_RMSE,font_size=**12**,target=p3)
;o_fn='Scatter_lst_lst_estimated.emf'
;p3.save,o_fn,border=40
;p4.save,o_fn,border=40
**End**
3 結果與分析:
由於代碼中是隨機數採樣,每次採樣訓練樣本數據不同,所以每次運行代碼可以得到不同的模型。以下是模型顯示:
模型1:
模型2:
模型3:
也可以修改代碼中的採樣數目,來改變訓練樣本數目,模型也會發生變化。如將其中的[0:10]改爲[0:20],對應的11修改爲21就可增加訓練樣本數目:
代碼:
ndvi_samples=ndvi_img[sort_c[**0**:**20**],*]
lst_samples=lst_img[sort_c[**0**:**20**],*]
ndvi_get=**reform**(ndvi_samples,**21***ndvi_rows, **1**)
lst_get=**reform**(lst_samples,**21***ndvi_rows, **1**)
模型4:
結論分析:
相關係數(R),是衡量兩個變量之間相關程度的係數,是判定變量之間線性相關性的一個相對指標。相關係數用字母R表示,相關係數R取值在±1之間,當R爲0時,表示兩個變量絕對不相關;當R大於0時,兩個變量正相關,即你增加我也增加,你減少我也減少;當R小於0時,兩個變量負相關,即你增加我減少,你減少我增加;當R等於1或-1時,表示兩個變量絕對相關。
相關係數R越接近於±1,兩個變量之間相關性越強。一般認爲:當R的絕對值爲0.7或更大時,兩個變量高度相關,即強相關;當R的絕對值在0.5-0.7之間時,兩個變量中度相關;當R絕對值在0.3-0.5之間時,兩個變量弱相關;當R絕對值低於0.3時,說明兩個變量之間幾乎不存在相關關係。
平均絕對誤差(MAE),MAE 的值越小,說明預測模型擁有更好的精確度。範圍[0,+∞),當預測值與真實值完全吻合時等於0,即完美模型;誤差越大,該值越大。
均方根誤差(RMSE),它表示誤差的平方的期望值,範圍[0,+∞),當預測值與真實值完全吻合時等於0,即完美模型;誤差越大,該值越大。
綜上,以上四種模型的相關係數R的絕對值值均在0.5-0.7之間,說同一時間NDVI值與LST中度相關。其中第四種模型R的絕對值最大,相關性更高,進一步說明,採樣數據越多模型相關性越好;對比四種模型的平均絕對誤差(MAE)和均方根誤差(RMSE),第四種模型這兩個量較前三種較小,說明其擁有更好的精確度,且誤差較小,更進一步說明,樣本數據越多,其擬合度越好,模型越精確。