How to convert netcdf to tiff

25 ビュー (過去 30 日間)
nuwanthi arampola
nuwanthi arampola 2019 年 7 月 15 日
コメント済み: nuwanthi arampola 2019 年 7 月 16 日
I'm working with netcdf file in Ocean Color website.
I want to know How to convert them in to tiff uding matlab coding.
Could you please any one help me in this matter?
  2 件のコメント
Guillaume
Guillaume 2019 年 7 月 15 日
NetCDF is a generic format for storing any sort of data. On the other hand, TIFF is a format for storing images only. So you'll have to clarify what you mean by converting netcdf to tiff.
nuwanthi arampola
nuwanthi arampola 2019 年 7 月 15 日
Yes exactly,
I want to get the cholorophill_ a data wich is containing in this netcdf file that are available in this following link "https://oceancolor.gsfc.nasa.gov/cgi/browse.pl?sen=am"

サインインしてコメントする。

回答 (2 件)

KSSV
KSSV 2019 年 7 月 15 日
  5 件のコメント
KSSV
KSSV 2019 年 7 月 15 日
編集済み: KSSV 2019 年 7 月 15 日
YOu have to read about the functions which are given in the code......simply copy pasting will not work. The error clearly says, there is no variable named latitude in the nc file. You have to use ncdisp and see on what variable is latitude named int he ncfile.
Don't attach code as a image snippet......copy paste it and copy the error which throws up here.
Guillaume
Guillaume 2019 年 7 月 15 日
編集済み: Guillaume 2019 年 7 月 15 日
Please, don't post screenshots of code, paste it as text (and format it with the button). We can't copy/paste screenshots into matlab for testing.
As I said, netcdf is a generic container for scientific data. Within that container you've got all sorts of variables whose name is decided by whoever creates the file. In order to read a netcdf file you need to use the same variable names that are stored in the file. As per KSSV link, you can get these names with ncdisp, ncinfo, etc.
As the error tells you, there is no latitude variable in your netcdf file. You'll have to find out for yourself what's in your file and adapt KSSV code accordingly, but the idea is there, use ncread to read whatever is in the file, and geotiffwrite to write whatever image is there as a tiff file.
I couldn't figure out how to download a file from the link you posted. You could also attach an example file.

サインインしてコメントする。


nuwanthi arampola
nuwanthi arampola 2019 年 7 月 16 日
OutFolder = 'D:\paper\practice2';
cd D:\paper\data\January
dinfo = dir('*.nc');
nfile = length(dinfo);
filenames = {dinfo.name};
for k = 1:nfile
file_name{k} = filenames{k};
lat = ncread(file_name{i},'latitude') ;
lon = ncread(file_name{i},'longititude') ;
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
  4 件のコメント
Guillaume
Guillaume 2019 年 7 月 16 日
So:
Is your problem solved or not?
If not, what is the problem currently? Have you found which variables are in your file and which one of them you want to save as a tiff file?
nuwanthi arampola
nuwanthi arampola 2019 年 7 月 16 日
No i did not solved it yet.
I'm stcuked with empty mind.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by