It's simple, just follow this step.....
Before create a script, make sure your Matlab has integrated with NetCDF toolbox, if don't have, you can search in google or any search engine to get toolbox, but in this post I use nctoolbox, for further information such as installation, guide and download nctoolbox open this site.
- SST file used here is NetCDF file, for example I use SST data from Earth System Research Laboratory (ESRL) NOAA which can be downloaded here.
- Download GSHHS Shapefile here as a coastline.
- Open Matlab and use this script.
clc
clear all
close all
utara=7;
selatan=-11;
barat=95;
timur=140;
negara=gshhs('gshhs_l.b',[selatan utara],[barat timur]);
dt=ncgeodataset('sst.mnmean.nc');
lon=dt.data('lon');
lat=dt.data('lat');
time=dt.data('time');
tgl=datestr(dt.time('time'));
for i=find(lon>180):length(lon)
lon(i)=lon(i)-360;
end
sst=dt{'sst'}(length(time),:,:);
sst=reshape(sst,size(sst,2),size(sst,3));
dx=1;
[lon_r,lat_r]=meshgrid(barat:dx:timur+2,selatan:dx:utara+2);
sst_x=interp2(lon,lat,sst,lon_r,lat_r,'spline');
pcolorjw(lon_r,lat_r,sst_x); shading interp;
hold on
geoshow (negara,'FaceColor',[.1 .7 .1]);
level=[negara.Level];
geoshow(negara(level==2),'Facecolor',[0 0 1]);
axis equal
axis([barat timur selatan utara])
%caxis([25 30])
title(['Suhu Permukaan Laut Pada ' tgl(length(time),:)],'FontWeight','Bold');
xlabel('Longitude','FontWeight','Bold');
ylabel('Latitude','FontWeight','Bold');
h=colorbar;
set(get(h,'title'),'String','Suhu (^{\circ}C)','FontWeight','Bold');
set(gcf,'PaperPositionmode','auto');
clear all
close all
utara=7;
selatan=-11;
barat=95;
timur=140;
negara=gshhs('gshhs_l.b',[selatan utara],[barat timur]);
dt=ncgeodataset('sst.mnmean.nc');
lon=dt.data('lon');
lat=dt.data('lat');
time=dt.data('time');
tgl=datestr(dt.time('time'));
for i=find(lon>180):length(lon)
lon(i)=lon(i)-360;
end
sst=dt{'sst'}(length(time),:,:);
sst=reshape(sst,size(sst,2),size(sst,3));
dx=1;
[lon_r,lat_r]=meshgrid(barat:dx:timur+2,selatan:dx:utara+2);
sst_x=interp2(lon,lat,sst,lon_r,lat_r,'spline');
pcolorjw(lon_r,lat_r,sst_x); shading interp;
hold on
geoshow (negara,'FaceColor',[.1 .7 .1]);
level=[negara.Level];
geoshow(negara(level==2),'Facecolor',[0 0 1]);
axis equal
axis([barat timur selatan utara])
%caxis([25 30])
title(['Suhu Permukaan Laut Pada ' tgl(length(time),:)],'FontWeight','Bold');
xlabel('Longitude','FontWeight','Bold');
ylabel('Latitude','FontWeight','Bold');
h=colorbar;
set(get(h,'title'),'String','Suhu (^{\circ}C)','FontWeight','Bold');
set(gcf,'PaperPositionmode','auto');
here some sample I get,
Mohon maaf kenapa ketika mencapai perintah ini:
ReplyDeletesst_x=interp2(lon,lat,sst,lon_r,lat_r,'spline');
muncul peringatan
Error using griddedInterpolant
The grid vectors are not strictly monotonic increasing.
Error in interp2/makegriddedinterp (line 214)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 127)
F = makegriddedinterp({X, Y}, V, method,extrap);
yg menandakan data yg dibaca tidak urut..
mohon solusinya
maaf ketinggalan..
Deletesepertinya akibat dari sintak ini deh
for i=find(lon>180):length(lon)
lon(i)=lon(i)-360;
end
mohon dijelaskan ini untuk apa
terima aksih