MATLAB: How to change the origin of geographic vector data without using a projection in Mapping Toolbox in MATLAB 7.7 (R2008b)

centerchangemappingMapping Toolboxoriginrotatetoolbox

I know I can change the origin of my map data using the AXESM function. However, this requires that I define a map projection.
For example:
load coast; figure
axesm('mercator','Origin',[0 -180 0])
plotm(lat,long,'color',[.75 .75 .75])
How can I change the origin without defining a map projection?

Best Answer

The origin of a geographic data set can be changed by either applying a projection or using the ROTATEM function supplied by Mapping Toolbox.
It is usually preferable to change the origin of geographic data by applying a projection by using the AXESM with the 'origin' parameter, as this avoids changing the original data.
Alternatively, the ROTATEM command can be used as the following code illustrates:
% load data
s=load('coast');
land = shaperead('landareas', 'UseGeoCoords', true);
% rotate coordinates to new origin
new_origin=[0,-180];
[lat,lon]=rotatem(s.lat,s.long,new_origin,'inverse','degrees');
[llat,llon]=cellfun(@(lt,ln) rotatem(lt,ln,new_origin,'inverse','degrees'),{land.Lat},{land.Lon},'uniformoutput',false);
% reconstruct the rotated land structure
land=struct('Geometry',{land.Geometry},'BoundingBox',{land.BoundingBox},'Lon',llon,'Lat',llat,'Name',{land.Name});
% plot the result
plot(lon,lat,'b.');
hold on
geoshow(land, 'FaceColor', [0.5 0.7 0.5])