Plot data from Netcdf file with latitude, longitude

19 Ansichten (letzte 30 Tage)
Sayantan Sahu
Sayantan Sahu am 23 Jun. 2022
Beantwortet: Paolo Volpe am 16 Dez. 2022
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;

Antworten (2)

CHIRANJIT DAS
CHIRANJIT DAS am 24 Jun. 2022
Bearbeitet: CHIRANJIT DAS am 24 Jun. 2022
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 am 16 Dez. 2022
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!

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by