学习笔记之 基于matlab的GIMMS3G-NDVI数据处理-从nc文件解析到月和年最大合成tif

GIMMS的NDVI数据常常用来进行长时间序列的植被情况分析,最新的NDVI3g数据集,时间跨度为1982-2015年,半月合成,空间分辨率大致为8km(0.08333度),下载地址https://nex.nasa.gov/nex由于下载下来的是nc文件,部分用户可能不熟悉该数据格式,无法很好的使用该数据集,本文提供一套基于matlab的处理方式。

% @author [email protected]
lon=ncread('F:\Global\NDVI3g\ndvi3g_geo_v1_2015_0712.nc4','lon');
lat=ncread('F:\Global\NDVI3g\ndvi3g_geo_v1_2015_0712.nc4','lat');
%tmn=ncread('C:\Users\lenovo\Documents\Tencent Files\1079192939\FileRecv\月最低气温数据集_2000_2002\tmn_2000_2002.nc','tmn');
lonlim_left=-180;
lonlim_right=180;
latlim_top=90;
latlim_bottom=-90;
GeoRef = georasterref('Rastersize',[2160,4320],'Latlim',[latlim_bottom,latlim_top],'Lonlim',[lonlim_left,lonlim_right]);
i=1;
k=[1:12];
m=1;
year=[1982  1982    1983    1983    1984    1984    1985    1985    1986    1986    1987    1987    1988    1988    1989    1989    1990    1990    1991    1991    1992    1992    1993    1993    1994    1994    1995    1995    1996    1996    1997    1997    1998    1998    1999    1999    2000    2000    2001    2001    2002    2002    2003    2003    2004    2004    2005    2005    2006    2006    2007    2007    2008    2008    2009    2009    2010    2010    2011    2011    2012    2012    2013    2013    2014    2014    2015    2015
];
format='monthNDVI3g.tif';
montha=[1:6];
monthb=[7:12];
e=dir(fullfile('F:\Global\NDVI3g','*.nc4'));
while i<=length(e)
    a=ncread(e(i).name,'ndvi');
    while m<=length(k)
    j= m+1;
    h=j/2;
    b1=max(a(:,:,k(j)),a(:,:,k(m)));
    b=rot90(b1);
    m=m+2;
    if mod(i,2)==0
        g=monthb;
    else
        g=montha;
    end
    name1=strcat(int2str(year(i)),int2str(g(h)),format);
    geotiffwrite(name1,b,GeoRef);
    end
    m=m-12;
    i=i+1;
end

通过上述代码可直接输出每个月的TIF数据,而不用引入样例数据了。

猜你喜欢

转载自blog.csdn.net/weixin_44913294/article/details/112132857