1、实验目的:NASA提供的物候产品的栅格值是距离1970年1月1日的天数,但我们用于时空分析时习惯于转换为一年中的第几天的格式,更加直观。
2、实验软件:MATLAB 2016b
3、实现步骤:
%初始化环境
clc
close all
clear
%定义投影
tifread='D:\clip\MCD12Q2.061_Greenup_0_doy2001001_aid0001.tif';
[aa,R] = geotiffread(tifread);
info=geotiffinfo(tifread);
% Input, the folder where the raster is to be converted
in_path = 'D:\clip\MCD12Q2.061_Greenup_0_doy';
% Input, the folder to store the converted raster
out_path = 'D:\MCD12Q2/convert\';
for year=2001:2021
data=imread(strcat(in_path,num2str(year),'001_aid0001.tif'));
data(data==65535)=nan;
start_date = datetime(1970, 1, 1);
end_date = datetime(year, 1, 1);
days_diff = days(end_date - start_date);
disp(['1970年1月1日距离2001年1月1日的天数为:', num2str(days_diff)]);
result=data-days_diff;
geotiffwrite(strcat(out_path,num2str(year),'_SOS.tif'),result,R,'GeoKeyDirectoryTag',info.GeoTIFFTags.GeoKeyDirectoryTag)
end
根据需要修改输入输出路径以及循环的年数,有问题的友友欢迎私信~