Plot data from Netcdf file with latitude, longitude
20 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a Netcdf file that has latitude, longitude and variable. The latitude is 1800x1 single, longitude 3600x1 single and the variable is 3600x1800 single. My objective is to plot the variable in the colorbar axis with the latitude as the y-axis and the longitude as the x-axis. I have used the following lines of code to extract the data and create a meshgrid as per some online instructions. However I am not sure, how to proceed with plotting the relevant data on a map with geographical limits from 37 N to 42 N and 78 W to 75 W.
% Read lat, lon, and variable from netcdf
latitude = ncread('v50.nc','lat');
longitude = ncread('v50.nc','lon');
variable1 = ncread('v50.nc','var');
% Convert lat and lon into a grid 1800x3600
[X,Y]=meshgrid(longitude, latitude);
latitude = Y; longitude = X;
0 个评论
回答(2 个)
CHIRANJIT DAS
2022-6-24
编辑:CHIRANJIT DAS
2022-6-24
contourf(longitude,latitude,variable1');
colorbar
hold on
load coast
plot(long,lat,'k','linewidth',1)
axis([75 78 37 42])
Try this. Good luck
0 个评论
Paolo Volpe
2022-12-16
Hello there,
I have the same question. I am trying to plot, through the "contourf" function, the visibility data of a specific region as function of latitude and longitude but the size of this latter is different from the size of data. My latitude and longitude are a vector 36x1 while my data are 8928x36(because they are visibility values for 372 days and 24 hours of sampling and 36 is the number of possible combination between my 6 values of Latitude and 6 of Longitude). How can I do it? I cannot find anything correlated to my case. Thank you!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NetCDF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!