Plot data from Netcdf file with latitude, longitude

조회 수: 20 (최근 30일)
Sayantan Sahu
Sayantan Sahu 2022년 6월 23일
답변: Paolo Volpe 2022년 12월 16일
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;

답변 (2개)

CHIRANJIT DAS
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

Paolo Volpe
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!

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by