MATLAB数据预处理:Gleam 3.6数据处理与nc_tif格式分享

各位老师,同学大家好

此处为基于matlab处理的源代码,使用nc文件内置的日期及日历编写输出名称

此处为简单的处理的代码,高手请绕路,仅作为文章内容进行记录

%%
clc
clear
%%

% 设置数据文件名和保存路径
filename = 'Ew_1980-2021_GLEAM_v3.6a_MO.nc';% SMsurf SMroot S Ew Et Es Ep Ei Eb E
output_path = 'E:\测试\gleammonth\Ew_1980-2021_GLEAM\';
%fl='CSR_GRACE_GRACE-FO_RL06_Mascons_all-corrections_v02.nc'
% 打开nc数据文件
ncid = netcdf.open(filename,'NC_NOWRITE');
ncdisp(filename)
%ncdisp(fl)
% 获取时间变量的数据
timeid = netcdf.inqVarID(ncid,'time');
time = netcdf.getVar(ncid,timeid);

% 获取经度和纬度变量的数据
lonid = netcdf.inqVarID(ncid,'lon');
lon = netcdf.getVar(ncid,lonid);
latid = netcdf.inqVarID(ncid,'lat');
lat = netcdf.getVar(ncid,latid);

% 获取水平变量的数据
% 关闭nc数据文件
netcdf.close(ncid);

% 获取时间维度的信息
nt = length(time);
ncdisp(filename)
%timeunits = netcdf.getAtt(ncid,timeid,'Units');
%timecalendar = netcdf.getAtt(ncid,timeid,'calendar');
timeunits = 'days since 1980-01-31 00:00:00';
timecalendar ='proleptic_gregorian';
timebase = datenum('1980-01-31 00:00:00','yyyy-mm-dd HH:MM:SS');
timevec = datevec(timebase + double(time),timeunits,timecalendar);
year = timevec(:,1);
month = timevec(:,2);
    lwe_thickness=ncread(filename,'Ew'); %修改变量
    lon=double(ncread(filename,'lon'));
    lat=double(ncread(filename,'lat'));
% 将数据保存为TIF格式文件
for i = 1:nt
    lwe=lwe_thickness(:,:,nt);
    % 构建文件名
    lwe=rot90(lwe);
    outname = sprintf('%d-%02d',year(i),month(i))
    filepath = fullfile(output_path,outname);
    R=georasterref('RasterSize',size(lwe),'Latlim',[double(min(lat)) double(max(lat))],'Lonlim',[double(min(lon)) double(max(lon))]);
    % 保存为TIF格式文件
    geotiffwrite([output_path, '\',outname,'.tif'],lwe,R)
   % geotiffwrite();
end

此处为30天的分享期限

gleam原数据

链接:https://pan.baidu.com/s/1WJHTWR6rEti00tYvMZMNrg?pwd=xi4b 

提取码:xi4b 

--来自百度网盘超级会员V4的分享

以下是处理好的gleam数据

整体数据类型

数据内容处理后结果

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空