Prev: Running the generated M-file from cftool
Next: Loading an image WITHOUT image processing toolbox
From: Patrick on 1 Mar 2010 18:13 I'm still looking for some ideas on how to get my contour lines to always go to the edges of my map. I've used contourm for various meteorological datasets now, and this is always a problem. The code I attached in the orignal post below might be more than needed. The actual contourm command is toward the bottom and is repeated here: [c,h]=contourm(LATi,LONi,hgtsi,V,'k','LineWidth',1.5); The arrays are for latitude, longitude, and the corresponding values of the variable that I'm plotting (geopotential height). The program is plotting the data without errors, but it comes out looking a bit crude with the truncated countour lines. Thanks for any tips you might have. "Patrick " <gallagjo(a)interchange.ubc.ca> wrote in message <hi5fcp$ckg$1(a)fred.mathworks.com>... > I'm using contourm to plot the weather variable of geopotential height from a netCDF file. I can get the data to plot at my desired contour interval, but there are gaps showing up near the edges, i.e. the contour lines don't always come all the way to the edges of the lat/lon frame. I interpolated the height values from a 2.5 x 2.5 degree grid to 0.5 x 0.5 deg. I'm not sure why these gaps are showing up and would like to make it so the contours always go to the frame boundaries. > Here's the relevant code: ('hgts' is my data array with same dimensions as 'LON' and 'LAT') > > %create a finer lat/lon grid (every 0.5 deg instead of every 2.5 > %deg) for use in interpolating height values > lati=55:-0.5:45; > loni=-135:0.5:-115; > [LONi LATi]=meshgrid(loni, lati); > > %interpolate hts to finer grid and convert to double (otherwise > %contourm won't be happy) default is linear interp. > hgtsi=interp2(LON,LAT,hgts1,LONi,LATi); > hgtsi=double(hgtsi); > %find highest and lowest height values > loht1=min(hgtsi); > hiht1=max(hgtsi); > loht2=min(loht1); > hiht2=max(hiht1); > > %round low ht up to nearest 10 (for plotting) > loht3=loht2/10; > loht4=ceil(loht3); > loht=loht4*10; > %round hi ht down to nearest 10 > hiht3=hiht2/10; > hiht4=floor(hiht3); > hiht=hiht4*10; > V=loht:30:hiht; %use this vector to make contour interval 30m > > %open a map figure of the area and draw the province outlines > figure('Color','white') > worldmap([45 55],[-135 -115]) > canada = shaperead('province/PROVINCE.SHP','UseGeoCoords',true); > geoshow(canada); > > %contour the height lines > [c,h]=contourm(LATi,LONi,hgtsi,V,'k','LineWidth',1.5); > > %make label spacing wide enough to force only 1 label per contour > ht=clabel(c,h,'LabelSpacing',500);
|
Pages: 1 Prev: Running the generated M-file from cftool Next: Loading an image WITHOUT image processing toolbox |