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
处理nc后缀的数据
最新推荐文章于 2024-05-09 23:40:55 发布