使用MATLAB批量将MCD12Q2物候产品数据初始值转换为儒略日

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

根据需要修改输入输出路径以及循环的年数,有问题的友友欢迎私信~

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值