sen+mk
作者:互联网
sen:
[a,R]=geotiffread('E:\2015npp.tif');
info=geotiffinfo('E:\2015npp.tif');
[m,n]=size(a);
cd=5;
datasum=zeros(m*n,cd)+NaN;
k=1;
for year=2015:2019
filename=['E:\npp\clip\',int2str(year),'npp.tif'];
data=importdata(filename);
data=reshape(data,m*n,1);
datasum(:,k)=data;
k=k+1;
end
trend=zeros(m,n)+NaN;
for i=1:size(datasum,1)
data=datasum(i,:);
if min(data)>0
valuesum=[];
for k1=2:cd
for k2=1:(k1-1)
cz=data(k1)-data(k2);
jl=k1-k2;
value=cz./jl;
valuesum=[valuesum;value];
end
end
value=median(valuesum);
trend(i)=value;
end
end
filename=['E:\基于sen的npp变化趋势.tif'];
geotiffwrite(filename,trend,R,'GeoKeyDirectoryTag',info.GeoTIFFTags.GeoKeyDirectoryTag)
mk:
[a,R]=geotiffread('E:\2015npp.tif');
info=geotiffinfo('E:\2015npp.tif');
[m,n]=size(a);
cd=5;
datasum=zeros(m*n,cd)+NaN;
p=1;
for year=2015:2019
filename=['E:\npp\clip\',int2str(year),'npp.tif'];
data=importdata(filename);
data=reshape(data,m*n,1);
datasum(:,p)=data;
p=p+1;
end
sresult=zeros(m,n)+NaN;
for i=1:size(datasum,1)
data=datasum(i,:);
if min(data)>0
sgnsum=[];
for k=2:cd
for j=1:(k-1)
sgn=data(k)-data(j);
if sgn>0
sgn=1;
else
if sgn<0
sgn=-1;
else
sgn=0;
end
end
sgnsum=[sgnsum;sgn];
end
end
add=sum(sgnsum);
sresult(i)=add;
end
end
vars=cd*(cd-1)*(2*cd+5)/18;
zc=zeros(m,n)+NaN;
sy=find(sresult==0);
zc(sy)=0;
sy=find(sresult>0);
zc(sy)=(sresult(sy)-1)./sqrt(vars);
sy=find(sresult<0);
zc(sy)=(sresult(sy)+1)./sqrt(vars);
geotiffwrite('E:\2015-2019MK检验结果.tif',zc,R,'GeoKeyDirectoryTag',info.GeoTIFFTags.GeoKeyDirectoryTag);
sen+mk:
[a,R]=geotiffread('E:\2015npp.tif');
info=geotiffinfo('E:\2015npp.tif');
mkdata=importdata('E:\2015-2019MK检验结果.tif');
sen_value=importdata('E:\2015-2019基于sen的npp变化趋势.tif');
sen_value(abs(mkdata)<1.96)=NaN;
geotiffwrite('E:\2015-2019通过显著性95%的sen+mk趋势结果.tif',sen_value,R,'GeoKeyDirectoryTag',info.GeoTIFFTags.GeoKeyDirectoryTag);
标签:datasum,2015npp,mk,cd,sen,tif,data 来源: https://blog.csdn.net/xiaoxie_qingfa/article/details/116298057