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

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

NetCDF格式转换TIFF-以全球GIMMS3gNDVI数据为例1.全球GIMMS3gNDVI数据格式为.nc4.通过Matlab中的ncdisp即可查看数据内容。2.数据范围为全球尺度,[-9090][-180180]3.每个GIMMS3gNDVI数据中包含十二幅栅格影像,时间尺度为每月两幅。Matlab代码如下%%clear;clc%%settheinputpathforcontaininginputdataInputPath='input\';%readthenerCDF4file%initialimagelat[-9090]lon[-180180]filename='*.nc4';OutputPath=(['output\']);ifexist(OutputPath,'dir')==0%whenthedirexist,thevalueis7,orthevalueis0mkdir(OutputPath);%buildthenewdirectendIfiles=dir([InputPath,filename]);nIfiles=length(Ifiles);%%addthereferenceinformation%setthemaximumandminimunlatitudeandlongitudelatlim=[-9090];lonlim=[-180180];%definethegeo-referenceR=georefcells(latlim,lonlim,[36007200],'ColumnsStartFrom','north');fornf=1:nIfilesIfilename=Ifiles(nf).name;Ifiletime=Ifilename(end-6);year=Ifilename(end-12:end-9);year=str2double(year);IData=ncread([InputPath,Ifilename],'ndvi');%each.nc4filecontain12NDVIimagesinhalfyearifstr2double(Ifiletime)==1Imonth=1;elseImonth=7;endfori=1:12ndvidata=IData(:,:,i);ndvidata=ndvidata';%resamplethedatato0.05degreendvi05deg=imresize(ndvidata,[36007200],'nearest');ndvi05deg=double(ndvi05deg)/10000;ndvi05deg(ndvi05deg(:,:)=0)=NaN;ifmod(i,2)==0ndviname=year*10000+Imonth*100+2;ndviname=num2str(ndviname);%savethematfilesave([OutputPath,ndviname,'.mat'],'ndvi05deg','-v7.3');%saveaTIFFimagegeotiffwrite([OutputPath,ndviname],ndvi05deg,R);%%converttheNDVIfromhalfmonthtomonth%choosethemaxinumasthemonthndvivlaueNDVImax=ndvi05deg;C1=(NDVImax-NDVI1=0);C2=(NDVI1-NDVImax0);NDVImon=C1.*NDVImax+C2.*NDVI1;%savethematfilendviMoname=year*100+Imonth;ndviMoname=num2str(ndviMoname);save([OutputPath,ndviMoname,'.mat'],'NDVImon','-v7.3');%saveaTIFFimagegeotiffwrite([OutputPath,ndviMoname],NDVImon,R);clearC1C2NDVI1NDVImaxNDVImon;Imonth=Imonth+1;elsendviname=year*10000+Imonth*100+1;ndviname=num2str(ndviname);%savethematfilesave([OutputPath,ndviname,'.mat'],'ndvi05deg','-v7.3');%saveaTIFFimagegeotiffwrite([OutputPath,ndviname],ndvi05deg,R);NDVI1=ndvi05deg;endendend

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功