MATLAB: How to read ASCII grid format

asciiformatgriddingintervalslatitudelinspacelongitude

Hello,
I am confused about how to read this ASCII grid I have.
Let's call it A.asc A has a resolution of 0.5 x 0.5 degrees
ncols 720
nrows 360
xllcorner -180.25
yllcorner -89.75
cellsize 0.5
NODATA_value -9999
I am confused about the gridding format because this dataset should be worldwide and have even intervals of 0.5
How should I make the latitude and longitude vectors?
If I use linspace, I will not get a 360×1 vector evenly spaced by 0.5
Does it go from -180.25 to 0? If so, then what happened to the coordinates between 0 and 180?
Thank you,
Melissa

Best Answer

Since you already have Mapping Toolbox, the easiest is to use pix2latlon(). Something like this:
% Read your data
[Data,RefMat]= arcgridread('youtfile.shp');
% prepare a lat/lon grid
[nrows,ncols,~]=size(Data);
[row,col]=ndgrid(1:nrows,1:ncols);
[lat,lon]=pix2latlon(RefMat,row,col);
% NOTE: lat(:,1) and lon(1,:)' are the vectors that you are looking
% display a sample field
figure,
worldmap([min(lat(:)) max(lat(:))],[min(lon(:)) max(lon(:))])
geoshow(lat,lon,Data(:,:,1),'DisplayType','surface');
% display on a globe (more fancy)
figure
axesm('globe','Geoid',earthRadius)
meshm(Data(:,:,1), RefMat)
view(3)
set(gca,'Box','off')