收藏 分销(赏)

NetCDF格式转换TIFF-以全球GIMMS3g-NDVI数据为例.docx

上传人:二*** 文档编号:4776813 上传时间:2024-10-12 格式:DOCX 页数:2 大小:126.45KB 下载积分:5 金币
下载 相关 举报
NetCDF格式转换TIFF-以全球GIMMS3g-NDVI数据为例.docx_第1页
第1页 / 共2页
本文档共2页,全文阅读请下载到手机保存,查看更方便
资源描述
NetCDF格式转换TIFF-以全球GIMMS3g NDVI数据为例 1. 全球GIMMS3g NDVI数据格式为.nc4. 通过Matlab中的 ncdisp即可查看数据内容。 2. 数据范围为全球尺度,[-90 90] [-180 180] 3. 每个GIMMS3g NDVI数据中包含十二幅栅格影像,时间尺度为每月两幅。 Matlab 代码如下 %% clear;clc %% set the input path for containing inputdata InputPath = 'input\'; % read the nerCDF4 file % initial image lat [-90 90] lon[-180 180] = '*.nc4'; OutputPath=(['output\']); if exist(OutputPath,'dir')==0 %when the dir exist, the value is 7,or the value is 0 mkdir(OutputPath); %build the new direct end Ifiles = dir([InputPath,]); nIfiles = length(Ifiles); %% add the reference information % set the maximum and minimun latitude and longitude latlim = [-90 90]; lonlim = [-180 180]; % define the geo-reference R = georefcells(latlim,lonlim,[3600 7200],'ColumnsStartFrom','north'); for nf =1:nIfiles I = Ifiles(nf).name; I = I(end-6); year = I(end-12:end-9); year = str2double(year); IData = ncread([InputPath,I],'ndvi'); % each .nc4 12 NDVI images in half year if str2double(I) ==1 Imonth = 1; else Imonth = 7; end for i =1:12 ndvidata = IData(:,:,i); ndvidata = ndvidata'; % resample the data to 0.05 degree ndvi05deg=imresize(ndvidata,[3600 7200],'nearest'); ndvi05deg= double(ndvi05deg)/10000; ndvi05deg(ndvi05deg(:,:)<= 0)=NaN; if mod(i,2) == 0 ndviname = year*10000+Imonth*100+2; ndviname = num2str(ndviname); % save the mat file save([OutputPath,ndviname,'.mat'],'ndvi05deg','-v7.3'); % save a TIFF image geotiffwrite([OutputPath,ndviname],ndvi05deg,R); %% convert the NDVI from half month to month % choose the maxinum as the month ndvi vlaue NDVImax=ndvi05deg; C1=(NDVImax-NDVI1>=0); C2=(NDVI1-NDVImax>0); NDVImon=C1.*NDVImax+C2.*NDVI1; % save the mat file ndviMoname = year*100+Imonth; ndviMoname = num2str(ndviMoname); save([OutputPath,ndviMoname,'.mat'],'NDVImon','-v7.3'); % save a TIFF image geotiffwrite([OutputPath,ndviMoname],NDVImon,R); clear C1 C2 NDVI1 NDVImax NDVImon; Imonth = Imonth+1; else ndviname = year*10000+Imonth*100+1; ndviname = num2str(ndviname); % save the mat file save([OutputPath,ndviname,'.mat'],'ndvi05deg','-v7.3'); % save a TIFF image geotiffwrite([OutputPath,ndviname],ndvi05deg,R); NDVI1=ndvi05deg; end end end
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服