Enter data on a worldmap

68 views (last 30 days)
은진
은진 on 18 Nov 2024 at 7:09
Commented: 은진 on 28 Nov 2024 at 7:35
I want to show precipitation data on the world map
This code does not appear to indicate the exact amount of precipitation in latitude and longitude
Please help me
clc; clear all;
fnm = 'precip.mon.ltm.1981-2010.nc'
lon=double(ncread(fnm,'lon'));
lat=double(ncread(fnm,'lat'));
time=ncread(fnm,'time');
dateT=datetime(1800,01,01,00,00,00)+days(time);
precip=ncread(fnm,'precip');
load coastlines; % Load coastline data
[X, Y] = meshgrid(lon, lat);
for month = 1:12
f = figure;
% Create world map projection
worldmap('world');
setm(gca, 'Origin', [0 180 0]); % Set map origin to be the equator
% Plot precipitation data on the world map
surfm(X', Y', precip(:, :, month)); % Use surfm to plot data on the map
cmap = brewermap(16, 'BrBG'); % Generate the colormap
colormap(cmap); % Apply the colormap to the current figure
cb = colorbar; % Create a colorbar
cb.Label.String = 'mm/day';
clim([0 16]); % Set color axis limits
cb.Ticks = 0:1:16;
% Overlay coastlines
plotm(coastlat, coastlon, 'k', 'LineWidth', 1); % Plot coastlines on top of precipitation data
% Add title with month name
title(sprintf('Average Monthly Precipitation (1981-2010) - %s', datestr(dateT(month), 'mmmm')));
% Save each figure as an image file
filename = sprintf('E:\\Koppen-Geiger climate classes\\Average_Monthly_Precipitation%d.png', month);
saveas(f, filename);
close(f);
end
  5 Comments
Kanishk
Kanishk on 25 Nov 2024 at 5:41
Hi @은진, With code and data provided I was able to produce this image.
Could you clarify what is the issue or any missing feature you expect from the plot?
은진
은진 on 28 Nov 2024 at 7:35
The precipitation data seems to have mismatched latitude and longitude coordinates.

Sign in to comment.

Answers (0)

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!