处理nc后缀的数据

clc;
close all;
filepath_1='G:\theone\yangzriver\2019\FY\';
img_path_list_1 = dir(strcat(filepath_1,'*.nc'));%
img_num = length(img_path_list_1);%获取图像总数量
for ii =1:img_num
    ncFilePath1= img_path_list_1(ii).name;
            
%     weizhi1 = strfind(ncFilePath1,'NRT');  %返回字符串的位置
%     weizhi2 = strfind(ncFilePath1, '02');
%     weizhi3 = strfind(ncFilePath1, '03');
% %     if weizhi1==38
% %         if ismember(69,weizhi2)==1||ismember(69,weizhi3)==1   %或者等于69,23
% % ncdisp(ncFilePath1);
            ncid = netcdf.open(ncFilePath1);
            ncinfo(ncFilePath1);
            ncdisp(ncFilePath1);
            fprintf('%d %s\n',ii,strcat(ncFilePath1));
%             indfir=max(strfind(ncFilePath1,'_'));% max_
%             indlas=strfind(ncFilePath1,'n');%.
%             xlyb=ncFilePath1(indfir+1:indlas-1);
%             TG1 = ncread(ncFilePath1,'AvgSurfT_tavg');
% %             TG1 = ncread(ncFilePath1,'TG_DAY_AVG');
            CLM = ncread(ncFilePath1,'CLM');
%             lat =Latitude;
%             lon = nominal_satellite_subpoint_lon;
%             lon=ncread(ncFilePath1,'lon');%读取经度变量  nominal_satellite_subpoint_lat  'Latitude' 'Longitude'
%             TG1=TG1*50;
%             R = georasterref('RasterSize', size(TG1'),'Latlim', [double(min(lat)) double(max(lat))], 'Lonlim', [double(min(lon)) double(max(lon))]);%地理栅格数据参考对象(类)
%            %% 裁剪
%             %lon1,lat1为裁剪图片左上角经纬度,lon2,lat1为新图右下角经纬度
%             lon1=97;
%             lat1=36;
%             lon2=124;
%             lat2=21;
%             a = (lon1-R.LongitudeLimits(1,1))./R.CellExtentInLongitude+1;
%             b = (R.LatitudeLimits(1,2)-lat1)./R.CellExtentInLatitude+1;
%             c = (lon2-lon1)./R.CellExtentInLongitude+1;
%             d = (lat1-lat2)./R.CellExtentInLatitude+1;
%             newpic = imcrop(TG1',[a b c d]);
%             
%             %% 插值
%             [p,q] = size(newpic);
%             % original location
%             [X,Y] = meshgrid( 0:1:p-1, 0:1:q-1);
%             % target image size
%             p1 = 1801; q1 = 3241;
%             % new sampling location
%             [XI,YI] = meshgrid( 0:1:(p1-1), 0:1:(q1-1));
%             newpic=imresize(newpic,[1801 3241],'bilinear');
%
% %               newpic = griddata(X,Y,double(newpic'), XI,YI);
% %%            
% %             newpic = newpic';
% %             newpic=rot90(newpic,4);
% %             newpic=fliplr(newpic);
%             newpic=flipud(newpic);%上下
%             R = georasterref('RasterSize',size(newpic),'Latlim', [double(lat2) double(lat1)], 'Lonlim', [double(lon1) double(lon2)]);%地理栅格数据参考对象(类)
% %              outfilename_1=[ncFilePath1,'.tif'];
%             outfilename_1=['C:\Users\Administrator\Downloads\',xlyb,'.tif'];
% %              geotiffwrite(outfilename_1,newpic,R);
%             newpic=uint16(newpic);
% %             m=imread('mask_lumian.tif');
% %             for x=1:1801
% %                 for y=1:3241
% %                     if m(x,y)==0
% %                         newpic(x,y)=0;
% %                     end
% %                 end
% %             end
outfilename_1=[ncFilePath1,'.tif'];
            imwrite(CLM',outfilename_1);
%             netcdf.close(ncid);
% %         end
% %     end
end

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值