Matlab Class Home      Class Outline      Previous Task      Next Task      Main Class Page      Evaluation 14

Task 14.3 Detail: adding text and details to maps

Summary of new tools and commands.

Task: Extend the map created in task 14.2 to add city names over the locations of the cities. Include a frame on the figure.

A frame can be placed on a map with framem. This command is a toggle which means that if it is issued with no frame on the picture, then a frame is added. If there is a frame there, then it is removed.

More direct control is available with

 framem ON
which adds a frame if there is none but leaves the frame if it is already there. Similarly,
 framem OFF
turns the frame off or leaves it off. Finally,
 framem RESET
will redraw the frame based on the current properties. Note that the ON and OFF commands just change the visible property without making any other changes.

It is possible to put text on a map with textm which is the map companion command to text which we have already worked with. Again, the location is given with latitude and longitude, which is internally converted to plotter coordinates based on the map projection.

If you need to contour values over the surface of the earth, the map companion to contour is

 contourm(Lat,Lon,Z)
where Z is a 2d array of values to contour and the arrays Lat and Lon are 2d arrays giving the locations of the values in Z. There are a number of other options for locating the points to contour which can be found with help contourm.

Similarly, surfm produces a 3d surface plot over a map. The command is

 surfm(Lat,Lon,Z)
 
where the input arguments have the same meanings as explained above. There are similar alternative specification for locations as explained in help surfm. p> Flow chart for task
%%%  get locations of cities
%%%  create base world map for these cities
%%%  add coastline to the map
%%%  put symbols and names for cities on map
%%%  draw a line between cities
%%%  define offset for names
%%%  add city names near location
%%%  turn on frame

Script for task.

%%%  get locations of cities
 Loc=[33.7701 -118.1937;34.4437 139.6380 ;-53.1638 -70.9171];
 Name={'Long Beach';'Yokohama';'Punta Arenas'};
%%%  create base world map for these cities
  Latm=-60;LatM=50;Lonm=120;LonM=310;
  figure
   worldmap([Latm LatM],[Lonm LonM])
%%%  add coastline to the map
   geoshow('landareas.shp')
%%%  put symbols for cities on map
   plotm(Loc(:,1),Loc(:,2),'k*')
%%%  draw a line between cities
   hold on
   plotm([Loc(:,1); Loc(1,1)],[Loc(:,2); Loc(1,2)])
%%%  define offset for names
  pLat=2;pLon=-10;
%%%  add city names near location
 textm(Loc(1,1)+pLat,Loc(1,2)+pLon,char(Name(1)))
 textm(Loc(2,1)+pLat,Loc(2,2)+pLon,char(Name(2)))
 textm(Loc(3,1)+pLat,Loc(3,2)+pLon,char(Name(3)))
 mlabel ON;plabel ON;
%%%  turn on frame
 framem ON

Matlab Class Home      Class Outline      Previous Task      Next Task      Main Class Page      Evaluation 14


email: J. Klinck