Clear Filters
Clear Filters

overlaying appropriate basic, coastal map onto a geographical plot (nc)

7 views (last 30 days)
Hi
This is my second time using matlab, pardon me if I've missed something obivous..
I have a plot created from an nc file using ncdef.open
I'm wondering if there is a function that allows me to overlay a simple map detailling the coastline lines onto my image.
Currently, this is what my image looks like:
I've tried :
load coast
plot(long+180,lat,'w')
But the image is mirrored from the middle:
Is there a way which I can overlay a map that reads the longitudes,latitudes of my image so that it fits it's self on to my image?
Heres an attachment of my script:
fpath = '/Users/jackie/Desktop/data/access1.3/';
fname = 'CSIRO_access1.3_cli_2000_01.nc';
myFolder = fpath;
if ~isfolder(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder,'*.nc');
theFiles = dir(filePattern);
avgClia = zeros(144,91,40);
for i =1:60
baseFileName = theFiles(i).name;
fullFileName = fullfile(myFolder, baseFileName);
ncid=netcdf.open(fullFileName, 'NC_NOWRITE');
vid=netcdf.inqVarID(ncid,'cli');
clia=netcdf.getVar(ncid,vid);
avgClia = avgClia + clia;
netcdf.close(ncid);
end
avgClia = avgClia / 60;
ncid =netcdf.open([fpath,fname],'NC_WRITE');
vid=netcdf.inqVarID(ncid,'lon');
longitude=netcdf.getVar(ncid,vid);
vid=netcdf.inqVarID(ncid,'lat');
latitude=netcdf.getVar(ncid,vid);
vid=netcdf.inqVarID(ncid,'plev');
z1=netcdf.getVar(ncid,vid);
index = find(longitude<0);
longitude(index) = longitude(index)+360;
index1 = find(longitude<0);
longitude(index1) = longitude(index1)+360;
for d = 1:1
lon_b1 = 0;
lon_b2 = 360;
lat_b1 = -90;
lat_b2 = 90;
end
figure(1);
a = find (longitude>=lon_b1 & longitude<=lon_b2);
b = find (latitude>=lat_b1 & latitude<=lat_b2);
%z = find (z1>= 177 & z1 <= 215); plev = '200';
%z = find (z1>= 586 & z1 <= 624); plev = '600';
z = find (z1>= 897 & z1 <= 912); plev = '900';
lon = longitude(a);
lat1 = latitude(b);
clia = avgClia(a,b,z,d) * 1000000;
[XX,YY]=meshgrid(lon,lat1);
min_axis=floor(min(min(clia))/0.1)*0.1;
max_axis=ceil(max(max(clia))/0.1)*0.1;
% ScaleTick_step=4;
% cli1=flipdim(clia,2);
contourf(XX,YY,clia',1000,'linestyle','none');
caxis([min_axis,max_axis]);
ScaleTick_step=0.1;
ScaleTick=min_axis:ScaleTick_step:max_axis;
FactorName=cell(1,length(ScaleTick));
for i=1:length(ScaleTick)
FactorName{i}=num2str(ScaleTick(i));
end
hold on
%worldmap('world')
load coast
plot(long+180,lat,'w')
% xlim([0 360])
% hold on;
% %load coast
% %plot(long+180,lat,'w')
% %xlim([0 180])
% %plotm(coastlat,coastlon)
% %hold on
% %plot(lon,lat,'k')
h = colorbar;
set(h, 'ylim', [0 50])
colormap(jet)
%hold off
The nc file details the cloud ice ratio against pressure.
If theres a way to flip the image from the midddle, left to right, than I can load coast onto it correctly.
Thank you so much

Answers (1)

Kritika Singh
Kritika Singh on 24 Aug 2021
The base layer adds a simple map onto an image .You can find more information by referring to the following links.
Overlay layers can add information, such as state borders and coastlines, to a base layer map. The toolbox includes functions to draw lines, polygons, and web markers on a web map. Refer to the following link

Products

Community Treasure Hunt

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

Start Hunting!