www.gusucode.com > map 案例源码 matlab代码程序 > map/FitGriddedDataToGraticuleExample.m
%% Fit Gridded Data to Graticule % This example shows how to fit gridded data to the graticule. The example % fits the regular data grid |topo| using a coarse graticule, favoring % speed over precision in terms of positioning the grid on the map. But the % example shows how to fit the data to a finer graticule. %% % Load a data grid. % Copyright 2015 The MathWorks, Inc. load topo %% % Create a referencing matrix. topoR = makerefmat('RasterSize', size(topo), ... 'Latlim', [-90 90], 'Lonlim', [0 360]); %% % Set up a Robinson projection. figure axesm robinson %% % Specify a 10-by-20 cell graticule. spacing = [10 20]; %% % Display data mapped to the graticule. h = meshm(topo,topoR,spacing); %% % Set the DEM colormap. Notice that for this coarse graticule, the edges of % the map do not appear as smooth curves. Previous displays used the % default [50 100] graticule, for which this effect is negligible. % Regardless of the graticule resolution, the grid data is unchanged. In % this case, the data grid is the 180-by-360 |topo| matrix, and regardless % of where it is positioned, the data values are unchanged. demcmap(topo) %% % Reset the graticule to a very fine grid using the |setm| function. Making % the mesh more precise is a trade-off of resolution versus time and memory % usage. You can also reset the graticule using the |meshgrat| function. setm(h,'MeshGrat',[200 400]) %% % Notice that the result does not appear to be any better than the original % display with the default [50 100] graticule, but it took much longer to % produce. There is no point to specifying a mesh finer than the data % resolution (in this case, 180-by-360 grid cells). In practice, it makes % sense to use coarse graticules for development tasks and fine graticules % for final graphics production.