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!