www.gusucode.com > map 案例源码 matlab代码程序 > map/ReorientGriddedDataExample.m
%% Reorient Gridded Data % This example shows how to transform a regular data grid into a new % one with its data rearranged to correspond to a new coordinate system % using the |neworig| function. You can transform coordinate systems of % data grids as well as vector data. When regular data grids are % manipulated in this manner, distance and azimuth calculations with the % map variable become row and column operations. %% % Load the |topo| data set and transform it to a new coordinate system in % which a point in Sri Lanka (7 degrees N, 80 degrees E) is the north pole. % Copyright 2015 The MathWorks, Inc. load topo origin = newpole(7,80) %% % Reorient the data grid with the |neworig| function, using this % orientation vector. Note that the result, |[Z,lat,lon]| , is a geolocated % data grid, not a regular data grid like the original |topo| data. [Z,lat,lon] = neworig(topo,topolegend,origin); %% % Display the new map, in normal aspect, as its orientation vector shows. % Note that every cell in the first row of the new grid is 0 to 1 degrees % distant from the point new origin. Every cell in its second row is 1 % to 2 degrees distant, and so on. In addition, every cell in a particular % column has the same great circle azimuth from the new origin. figure axesm miller latlim = [ -90 90]; lonlim = [-180 180]; gratsize = [90 180]; [lat,lon] = meshgrat(latlim,lonlim,gratsize); surfm(lat,lon,Z); demcmap(topo) mstruct = getm(gca); mstruct.origin