필터 지우기
필터 지우기

how to convert a netcdf file into a tiff/geotiff file

조회 수: 9 (최근 30일)
Sir Felix Otieno
Sir Felix Otieno 2018년 5월 2일
댓글: Sir Felix Otieno 2018년 5월 9일
i want to convert netcdf files to geotiff in matlab.any idea on how to go about it.

답변 (2개)

Reyadh Albarakat
Reyadh Albarakat 2018년 5월 7일
I recommend you to use "geotiffwrite". https://www.mathworks.com/help/map/ref/geotiffwrite.html.
  댓글 수: 3
Reyadh Albarakat
Reyadh Albarakat 2018년 5월 8일
Dear;
I wrote this code for you. Please try it!
%
OutFolder = 'Your Outputs Path';
cd Your Data Path
dinfo = dir('*.nc');
nfile = length(dinfo);
filenames = {dinfo.name};
for k = 1:nfile
file_name{k} = filenames{k};
lat = ncread(file_name{i},'lat') ;
lon = ncread(file_name{i},'lon') ;
A{k} = ncread(file_name{k},'MYD08_D3_6_AOD_550_Dark_Target_Deep_Blue_Combined_Mean');
A{k} = (double(A{k}));
R = georasterref('RasterSize',size(A{k}),'LatitudeLimits',[min(lat),max(lat)],'LongitudeLimits',[min(lon),max(lon)]);
tiffile{k} = strcat(filenames{k},'.tif') ;
geotiffwrite(fullfile(OutFolder,tiffile{k}),A{k},R);
end
Sir Felix Otieno
Sir Felix Otieno 2018년 5월 9일
OutFolder = 'C:\Users\Student\Desktop\phelix\SOFTWARES'; cd C:\Users\Student\Desktop\phelix\SOFTWARES dinfo = dir('*.nc'); nfile = length(dinfo); filenames = {dinfo.name}; for k = 1:nfile file_name{k} = filenames{k};
lat = ncread(file_name{i},'lat') ;
lon = ncread(file_name{i},'lon') ;
A{k} = ncread(file_name{k},'ch1');
A{k} = (double(A{k}));
R = georasterref('RasterSize',size(A{k}),'LatitudeLimits',[min(lat),max(lat)],'LongitudeLimits',[min(lon),max(lon)]);
tiffile{k} = strcat(filenames{k},'.tif') ;
geotiffwrite(fullfile(OutFolder,tiffile{k}),A{k},R);
end
Subscript indices must either be real positive integers or logicals.
Error in reference (line 9) lat = ncread(file_name{i},'lat') ; i am getting that error. you give me your e mail i send you the file i am using

댓글을 달려면 로그인하십시오.


Sir Felix Otieno
Sir Felix Otieno 2018년 5월 8일
i have tried to use geotiffwrite but my files are in netcdf format.i dont know how i can go about that

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by