How to plot satellite data?
38 views (last 30 days)
Show older comments
I am currently working with IDL to plot spectral images of trace gases concentration from satellite observation (such as TROPOMI on S5P and IASI on Metop satellites) but I want to switch to MATLAB. In this process I am having several trouble:
- I can not find a function or a tool to read native format images (.nat extension).
- I read files in NetCDF or HDF5 formats but I can not find a good way to plot this data.
I attacched an example of what I am trying to obtain. If some one has an sample code I would be grateful if he shared it.
2 Comments
Clare Davis
on 1 Feb 2019
Hello, I am having the same trouble - did you get a good answer in the end? Thanks
Answers (3)
Meg Noah
on 10 Jan 2020
Edited: Meg Noah
on 10 Jan 2020
Here's a solution
clc
close all
clear all
filename = 'W_XX-EUMETSAT-Darmstadt,HYPERSPECT+SOUNDING,METOPA+IASI_C_EUMP_20181108012658_62544_eps_o_l2.nc';
info = ncinfo(filename);
% to get a listing on console of variable names
varnames = {info.Variables.Name}';
idx = find(contains(varnames,'integrated_co') & ~contains(varnames,'integrated_co2'));
% learning about the data
Attributes = info.Variables(idx).Attributes;
for i = 1:length(Attributes)
if (isnumeric(Attributes(i).Value))
fprintf(1,'%s = %f\n',Attributes(i).Name,Attributes(i).Value);
else
fprintf(1,'%s = %s\n',Attributes(i).Name,Attributes(i).Value);
end
end
dataCO = ncread(filename,'integrated_co');
% they seem to have made the missing data value a really big value
minval = min(dataCO(:));
dataCO(dataCO == max(dataCO(:))) = -300;
maxval = max(dataCO(:));
fprintf(1,'minval = %f\n',minval);
fprintf(1,'maxval = %f\n',maxval);
minval = 2e-4;
maxval = 67e-4;
m = 63/(maxval-minval);
b = -m*minval;
scaleddataCO = uint8(m*dataCO+b);
scaleddataCO(dataCO<0) = nan; % missing data
colorvals = colormap(jet);
lat = ncread(filename,'lat');
lon = ncread(filename,'lon');
[ny,nx] = size(dataCO);
figure()
hold on
for i = 1:64
idx = find(scaleddataCO == i);
plot(lon(idx),lat(idx),'s', 'markerfacecolor',colorvals(i,:),'markeredgecolor','none');
end
xlim([-180 180])
ylim([-90 90]);
axis equal
axis tight
set(gca,'ytick',[-90 -60 -30 0 30 60 90]);
set(gca,'xtick',[-180 -150 -120 -90 -60 -30 0 30 60 90 120 150 180]);
grid on
box on
title('Integrated CO 10^{-4} kg/m^2');
colormap(jet)
hb = colorbar;
hb.Ticks = [0 0.2 0.4 0.6 0.8 1];
vals = linspace(2,67,6);
for j = 1:length(vals)
hb.TickLabels{j} = num2str(vals(j));
end
Here's how to plot it with map functions
hfig = figure('color','white','position',[32 200 1200 650]);
worldmap('World')
load coastlines
plotm(coastlat,coastlon,'k')
hfig.Name = 'Integrated CO';
hold on;
for i = 1:64
idx = find(scaleddataCO == i);
if (~isempty(idx))
plotm(lat(idx),lon(idx),'s', 'markerfacecolor',colorvals(i,:),'markeredgecolor','none');
end
end
title('Integrated CO 10^{-4} kg/m^2');
colormap(jet)
hb = colorbar('southoutside');
hb.Ticks = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
vals = linspace(2,67,11);
for j = 1:length(vals)
hb.TickLabels{j} = num2str(vals(j));
end
2 Comments
Visweshwaran R
on 27 Jan 2020
@Meg Noah, the code is well written and precise. I too faced the same problem in plotting the netCDF file for soil moisture data (ASCAT). While I try to adjust this code for my datasets, I faced a few problems.
1) After printing the min and max value. you have assigned the same with 2e-4 and 67e-4.What is the need for it?
2)While calculating 'm', you used 63, why?
3)Similarly, you used for loop till 64, why that number particularly?
I know these questions may be basic but I am struck and 5 min of your time will be really helpful to me.
Thank you in advance.
Hugo
on 24 Apr 2023
What would it look like without the missing data part?
I'm having trouble adapting the code to a random satellite ncDEF file cause it doesnt plot all my data
KSSV
on 8 Jan 2019
Reading netCDF files is very easy in MATLAB. You need to just know ncdisp, ncread ..once you have read the data use pcolor to get the data you wanted to plot.
7 Comments
KSSV
on 9 Jan 2019
What are the dimensions of each variable?
Try:
pcolor(lon,lat,int_co') ;
I have asked you to attach the data/ file so that you can get more help straight away.
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!