参考文献《基于Sen+Mann-Kendall 的北京植被变化趋势分析》
针对一维数组:
function Sen_slope,x1,y1,x2,y2
s = (y2 - y1)/(x2 - x1)
return,s
end
pro Sen_slope_array
COMPILE_OPT idl2
e = ENVI(/headless)
tic
;--------------------------------------------------------------------------------
;读取一维数组 arr
;--------------------------------------------------------------------------------
slope = [] ;创建空数组存放斜率s
for j = 0,n_elements(arr)-1 do begin
for i = 0, n_elements(arr)-1 do begin
if i lt j then begin
s = Sen_slope(i,arr[i],j,arr[j])
slope = [slope,s]
endif
endfor
endfor
print,slope.median() ;输出斜率的中值
toc
end