A Mapping package for Matlab (2024)

A Mapping package for Matlab (1)

You have collected your data, loaded it into Matlab , analyzed everything todeath, and now you want to make a simple map showing how it relates tothe world.

But you can't.

Instead you have to figure out how to save all your data, and thenread it into another program (like, for example GMT ), and then spend all thatextratime figuring out why it doesn't give you what you expected itwould...oryou can invest in Matlab's own mapping toolbox (with a similarly steeplearningcurve)... or not!

Announcing M_Map v1.4d! (updated Oct/08)

A Mapping package for Matlab (14)
A Mapping package for Matlab (16)

M_Map is a set of mapping tools written for Matlabv5 and later. These include:
  1. Routines to project data in 19 different spherical projections(and determine inverse mappings)
  2. A grid generation routine to make nice axes with limits eitherin lat/long terms or in planar X/Y terms.
  3. A coastline database (with 1/4 degree resolution)
  4. A global elevation database (1 degree resolution)
  5. Hooks into freely available high-resolution coastline andbathymetry databases
New in release 1.4d are
  1. Modifications to work around bugs in matlab7 contourf
  2. Robinson projection
  3. A few compatibility issues with current matlab versions
  4. Upgraded hooks into some databases.
New in release 1.4b are
  1. m_hatch for hatched and speckled patches
  2. old-fashioned speckled coastlines (good for B&W pics - see Example 13).
  3. m_lldist now also returns points on great circle geodesics.
  4. m_fdist, m_idist, and m_geodesic for geodesics on an ellipsoidalearth.
New in release 1.4 are
  1. m_pcolor
  2. m_coord (to allow for geographic and geomagnetic coordinatesystems)
  3. A very few minor bug fixes.
  4. Some hints about and examples of adding satellite image data toyourmaps.

    How to get M_Map

    You can download the M_Map toolbox either as a gzipped tar-file ,or as zip archive(Click on these links to download). If you are unpacking the zipfile MAKE SURE YOUALSO UNPACK SUBDIRECTORIES! Both are around 650k in size. Once you havethisarchive, read the Getting started sectionof the User's guide to correctlyinstall this toolbox, and sections 9and 10.1 to install TerrainBaseand GSHHS respectively.

    A number of examples have been given tohighlight the various capabilities of M_Map (thumbnails are shownabove).

    You can also get m_namebox (a set of utilities forautomatically adding names to your map), through its home page athttp://www.nersc.no/~even/.

    User's guide

    1. Getting started
    2. Specifying projections
      1. Azimuthal projections
      2. Cylindrical andPseudo-cylindrical projections
      3. Conic projections
      4. Miscellaneous globalprojections
      5. Yeah, but which projectionshould I use?
      6. Map scales
      7. Map coordinate systems-geographic and geomagnetic
    3. Coastlines and Bathymetry
      1. Coastline optionsA Mapping package for Matlab (21)
      2. Topography/Bathymetryoptions
    4. Customizing the axes
      1. Grid lines and labels
      2. Titles and x/ylabels
      3. Legend Boxes
    5. Adding your own data
      1. Drawing lines, text,arrows, patches, hatches, speckles, and contoursA Mapping package for Matlab (22)
      2. Drawing images and p_color
      3. Drawing tracklines
      4. Drawing range rings andgeodesicsA Mapping package for Matlab (23)
      5. Convertinglongitude/latitude to projection coordinates
      6. Converting projectioncoordinates to longitude/latitude
      7. Computing distances betweenpoints
    6. More complex plots
    7. Removing data from a plot
    8. Adding your own coastlines
      1. DCW political boundaries
    9. Adding your owntopography/bathymetry
      1. Sandwell and SmithBathymetry
    10. Using TerrainBase 5-minuteor ETOPO2 2-minute global bathymetry/topography
    11. Using the GSHHShigh-resolution coastline database
      1. Installing GSHHS
      2. Using GSHHS effectively
    12. M_Map toolbox contents anddescription
    13. Known Problems and Bugs
    14. Changes since lastrelease A Mapping package for Matlab (24)
    For information, help, suggestions, or bug reports, contact Rich Pawlowicz ,( rich@eos.ubc.ca )


    A number of people have helped out with suggestions, code fixes,etc. I am especially grateful for the work done by E. Firing, D.Byrne, M. Mann, J. Pringle, and J. E. Nilsen who have allcontributed code.


    1. M_Map Logo

    patch(.55*[-1 1 1 -1],.25*[-1 -1 1 1]-.55,'w');
    set(gcf,'units','inches','position',[2 2 3 3]);
    set(gcf,'paperposition',[3 3 3 3]);
    A Mapping package for Matlab (25)

    2.Lambert Conformal Conic projection of North American Topography

    m_proj('lambert','long',[-160 -40],'lat',[30 80]);
    m_coast('patch',[1 .85 .7]);
    A Mapping package for Matlab (26)

    3.Stereographicprojection of North Polar regions

    % Note that coastline is drawn OVER the grid because of the order in which
    % the two routines are called

    m_grid('xtick',12,'tickdir','out','ytick',[70 80],'linest','-');
    m_coast('patch',[.7 .7 .7],'edgecolor','r');

    A Mapping package for Matlab (27)

    4.Two Interrupted Projections of the World's Oceans

    Slongs=[-100 0;-75 25;-5 45; 25 145;45 100;145 295;100 290];
    Slats= [ 8 80;-80 8; 8 80;-80 8; 8 80;-80 0; 0 80];
    for l=1:7,
    'ytick',[-80:20:80],'yticklabels',[],'linest','-','color',[.9 .9 .9]);
    xlabel('Interrupted Sinusoidal Projection of World Oceans');
    % In order to see all the maps we must undo the axis limits set by m_grid calls:

    Slongs=[-100 43;-75 20; 20 145;43 100;145 295;100 295];
    Slats= [ 0 90;-90 0;-90 0; 0 90;-90 0; 0 90];
    for l=1:6,
    m_coast('patch',[.6 .6 .6]);
    xlabel('Interrupted Mollweide Projection of World Oceans');

    A Mapping package for Matlab (28)

    5. ObliqueMercatorProjection with quiver and contour data

    %% Nice looking data

    m_proj('oblique','lat',[56 30],'lon',[-132 -120],'aspect',.8);

    m_coast('patch',[.9 .9 .9],'edgecolor','none');
    hold on;
    xlabel('Simulated surface winds');

    m_coast('patch',[.9 .9 .9],'edgecolor','none');
    hold on;
    xlabel('Simulated something else');

    A Mapping package for Matlab (29)

    6.Miller Projection with Great Circle

    % Plot a circular orbit

    m_coast('color',[0 .6 0]);

    A Mapping package for Matlab (30)

    7. LambertConformalProjection with high-resolution bathymetry of Western Mediterranean

    m_proj('lambert','lon',[-10 20],'lat',[33 48]);
    A Mapping package for Matlab (31)

    8.Demonstration of fancy vectors

    m_vec % See code in m_vec.m for details
    A Mapping package for Matlab (32)

    9.Zoom in on Prince Edward Island to show different coastline resolutions

    % Example showing the default coastline and all of the different resolutions
    % of GSHHS coastlines as we zoom in on a section of Prince Edward Island.

    axes('position',[.35 .6 .37 .37]);
    m_proj('albers equal-area','lat',[40 60],'long',[-90 -50],'rect','on');
    m_coast('patch',[0 1 0]);
    m_text(-69,41,'Standard coastline','color','r','fontweight','bold');

    axes('position',[.09 .5 .37 .37]);
    m_proj('albers equal-area','lat',[40 54],'long',[-80 -55],'rect','on');
    m_gshhs_c('patch',[.2 .8 .2]);
    m_text(-80,52.5,'GSHHS\_C (crude)','color','m','fontweight','bold','fontsize',14);

    axes('position',[.13 .2 .37 .37]);
    m_proj('albers equal-area','lat',[43 48],'long',[-67 -59],'rect','on');
    m_gshhs_l('patch',[.4 .6 .4]);
    m_text(-66.5,43.5,'GSHHS\_L (low)','color','m','fontweight','bold','fontsize',14);

    axes('position',[.35 .05 .37 .37]);
    m_proj('albers equal-area','lat',[45.8 47.2],'long',[-64.5 -62],'rect','on');
    m_gshhs_i('patch',[.5 .6 .5]);
    m_text(-64.4,45.9,'GSHHS\_I (intermediate)','color','m','fontweight','bold','fontsize',14);

    axes('position',[.55 .23 .37 .37]);
    m_proj('albers equal-area','lat',[46.375 46.6],'long',[-64.2 -63.7],'rect','on');
    m_gshhs_h('patch',[.6 .6 .6]);
    m_text(-64.18,46.58,'GSHHS\_H (high)','color','m','fontweight','bold','fontsize',14);

    A Mapping package for Matlab (33)

    10.Tracklines and UTM projection

    m_proj('UTM','long',[-72 -68],'lat',[40 44]);

    % fake up a trackline


    A Mapping package for Matlab (34)

    11. Range rings

    xlabel('1000km range rings from Bangkok');
    A Mapping package for Matlab (35)

    12. Speckled boundary

     bndry_lon=[-128.8 -128.8 -128.3 -128 -126.8 -126.6 -128.8]; bndry_lat=[49 50.33 50.33 50 49.5 49 49]; clf; m_proj('lambert','long',[-130 -121.5],'lat',[47 51.5],'rectbox','on'); m_gshhs_i('color','k'); % Coastline... m_gshhs_i('speckle','color','k'); % with speckle added m_line(bndry_lon,bndry_lat,'linewi',2,'color','k'); % Area outline ... m_hatch(bndry_lon,bndry_lat,'single',30,5,'color','k'); % ...with hatching added. m_grid('linewi',2,'linest','none','tickdir','out','fontsize',12); title('Speckled Boundaries for nice B&W presentation (best in postscript format)','fontsize',14); m_text(-128,48,5,{'Pacific','Ocean'},'fontsize',18);
    A Mapping package for Matlab (36)

    13. Blue Ocean

     m_proj('miller','lat',[-75 75]);

    set(gca,'color',[.9 .99 1]); % Trick is to set this *before* the patch call.

    m_coast('patch',[.7 1 .7],'edgecolor','none');

    cities={'Cairo','Washington','Buenos Aires'};
    lons=[ 30+2/60 -77-2/60 -58-22/60];
    lats=[ 31+21/60 38+53/60 -34-45/60];

    for k=1:3,
    [range,ln,lt]=m_lldist([-123-6/60 lons(k)],[49+13/60 lats(k)],40);
    m_text(ln(end),lt(end),sprintf('%s - %d km',cities{k},round(range)));

    title('Great Circle Routes','fontsize',14,'fontweight','bold');

    A Mapping package for Matlab (37)

    Examples of satellite datamanipulation

    1. Global SST (or any variable on aglobalLat/Long grid)

    % NOAA/NASA Pathfinder AVHRR SST product
    % http://podaac.jpl.nasa.gov/sst/[P,map]=imread('../m_mapWK/199911h54ma-gdm.hdf');% Documentation for the 54km dataset gives
    % this formula for temperature
    P=0.15*double(P)-3; % deg C%...and defines this Lat/Long grid for the data
    Plat=90-.25-[0:359]*.5;Plon=-180+.25+[0:719]*.5;% Since the grid is rectangluar in lat/long (i.e. not
    % really a projection at all, althouhg it is included in
    % m_map under the name 'equidistant cyldindrical'), we
    % don't want to use the 'image' technique. Instead...
    % Create a grid, offsetting by half a grid point to account
    % for the flat pcolor
    [Plg,Plt]=meshgrid(Plon-0.25,Plat+0.25);m_proj('hammer-aitoff','clongitude',-150);% Rather than rearranging the data so its limits match the
    % plot I just draw it twice (you can see the join at 180W
    % because of the quirks of flat pcolor) (Note that
    % all the global projections have 360 deg ambiguities)
    m_pcolor(Plg,Plt,P);shading flat;colormap(map);
    hold on;
    m_pcolor(Plg-360,Plt,P);shading flat;colormap(map);m_coast('patch',[.6 1 .6]);
    m_grid('xaxis','middle');% add a standard colorbar.
    set(get(h,'title'),'string','AVHRR SST Nov 1999');

    A Mapping package for Matlab (38)

    2. SSM/I Ice cover (dataprovidedon a fixed grid)

    % SSM/I Ice concentration grids
    % (National Snow and Ice Data Center)P=hdfread('/mnt/cdrom/nasateam/northern/1991/feb/910222.tot','8-bitRaster Image #2');
    P(P==168)=101; % Land, no coverage.
    P(P==157)=102; % Bad data% SSM/I ice products are in a polar stereographic projection.
    % and the corner points of the grid are given. Here we just
    % use those given corner points and 'assume' everything will
    % work. It's not bad, although their projection actually uses
    % an ellipsoidal earth (m_map uses a spherical earth).m_proj('stereographic','latitude',90,'radius',55,'rotangle',45);% Convert bottom and left corner points to screen coords. This
    % is of course a kludge.
    [MAPX,dm]=m_ll2xy([279.26 350.03],[33.92 34.35],'clip','off');
    [dm,MAPY]=m_ll2xy([168.35 279.26],[30.98 33.92],'clip','off');clf
    % Plot data as an image
    colormap([jet(100);0 0 0;1 1 1]);m_coast('patch',[.6 .6 .6]);
    title('SSM/I Ice cover Feb 221991','fontsize',14,'fontweight','bold');h=colorbar('v');
    set(get(h,'ylabel'),'string','Total Ice Concentration (%)');

    A Mapping package for Matlab (39)

    3. Aerial photos on an UTM grid

    % This image comes from the TerraServer
    % (http://terraserver.microsoft.com/)
    % and has been georeferenced to UTM coords. The UTM projection
    % uses UTM coordinates on the screen (as long as the ellipse
    % parameter is set to something other than the default).
    [P,map]=imread('../m_mapWK/oncehome.jpeg');% Set the projection limits to the lat/long of image
    % corners.
    m_proj('UTM','long',[-71-6/60-30/3600 -71-4/60-43/3600],...
    'lat',[42+21/60+13/3600 42+22/60+7/3600],'ellipse','wgs84');clf;
    image([326400 328800],[46928004691200],P);set(gca,'ydir','normal');
    title('A home for certain nerds','fontsize',16);

    A Mapping package for Matlab (40)

    4. A subset ofa*global dataset (HDF format)

    % Ocean colour data fromhttp://seawifs.gsfc.nasa.gov/SEAWIFS.html
    % Take a 4km weakly average dataset and plot amapfor the Strait of
    % Georgia and outer coast. Note that most of thiscodeis used
    % for reading in and subsetting the data.LATLIMS=[47 51];
    LONLIMS=[-130 -121];% Note - This is probably not the most efficientwayto read and
    %handleHDF data, but I don't usually do this...
    % First, get the attribute data
    % And write it into a structure
    for k=1:59,
    nm=PI.Attributes(k).Name;nm(nm==' ')='_';
    if isstr(PI.Attributes(k).Value),
    end; % lon/lat of grid corners
    lat=[pin.Northernmost_Latitude:-pin.Latitude_Step:pin.Southernmost_Latitude];% Get the indices needed for the area of interest
    lglm=fix(diff(LONLIMS)/pin.Longitude_Step);% load the subset of data needed for the maplimitsgiven
    P=hdfread('A20040972004104.L3m_8D_CHLO_4KM','l3m_data','Index',{[iltilg],[],[ltlm lglm]});% Convert data into log(Chla) using the equationsgiven.Blank no-data.
    P=(pin.Slope*P+pin.Intercept); %log_10of chlaLT=lat(ilt+[0:ltlm-1]);LG=lon(ilg+[0:lglm-1]);
    [Plg,Plt]=meshgrid(LG,LT);% Draw the map...clf;
    m_pcolor(Plg,Plt,P);shading flat;
    set(get(h,'ylabel'),'String','Chla (\mug/l)');
    set(h,'ytick',log10([.5 1 2 3 5 10 2030]),'yticklabel',[.51 2 3 5 10 20 30],'tickdir','out');
    title(['MODIS Chla 'datestr(datenum(pin.Period_Start_Year,1,0)+pin.Period_Start_Day)' -> ' ...

    A Mapping package for Matlab (41)

    Last changed 30/Dec/2005. Questions and comments to rich@eos.ubc.ca
    A Mapping package for Matlab (2024)


    What is mapping in Matlab? ›

    Mapping Toolbox™ provides algorithms and functions for transforming geographic data and creating map displays. You can visualize your data in a geographic context, build map displays from more than 60 map projections, and transform data from a variety of sources into a consistent geographic coordinate system.

    What is the Mapper function in Matlab? ›

    This mapper uses a nested function to calculate several statistical quantities (count, mean, variance, and so on) for each chunk of input data, and then adds several key-value pairs to the intermediate KeyValueStore object.

    How to create a map in Matlab? ›

    Set up a new map by using the newmap function. By default, map axes objects use an Equal Earth projection centered on the prime meridian and the equator. Display the land areas using the geoplot function. You can use map axes to create maps in any supported projected coordinate reference system (CRS).

    How to plot geographic data in Matlab? ›

    geoplot( lat , lon ) plots a line in geographic coordinates. Specify latitude coordinates in degrees using lat , and specify longitude coordinates in degrees using lon . If the current axes is not a geographic or map axes, or if there is no current axes, then the function plots the line in a new geographic axes.

    What is mapping with example? ›

    Mapping applies to any set: a collection of objects, such as all whole numbers, all the points on a line, or all those inside a circle. For example, “multiply by two” defines a mapping of the set of all whole numbers onto the set of even numbers. A rotation is a map of a plane or of all of space into itself.

    What is mapping and how it works? ›

    maps use mathematical formulae to represent the Earth (an irregularly shaped sphere) onto this other surface. maps generally have a reference system which allows the location of a feature to be described. For example, latitude and longitude are used as a reference system on maps of the Earth.

    What is Mapper used for? ›

    In simple terms “mapper” is often associated with the concept of mapping between different data structures or objects. A mapper is a function or a class responsible for converting an object of one type into an object of another type. This process is commonly known as mapping.

    What is a mapper function? ›

    Mapper Functions are defined by a groovy script and input parameters that groovy script requires. The goal of a Mapper Function is to process topology data from an external system and prepare parameters for use by a template function.

    What does a mapper output? ›

    The output of the mapper act as input for Reducer which performs some sorting and aggregation operation on data and produces the final output. The Mapper mainly consists of 5 components: Input, Input Splits, Record Reader, Map, and Intermediate output disk.

    How to plot data on a map in MATLAB? ›

    geoplot( ax ,___) plots in the geographic axes or map axes specified by ax . h = geoplot(___) returns a Point , Line , or Polygon object. The type of object depends on the type of input. Use h to modify the properties of the plot object.

    What does a mapping function do? ›

    Map in Python is a function that works as an iterator to return a result after applying a function to every item of an iterable (tuple, lists, etc.). It is used when you want to apply a single transformation function to all the iterable elements. The iterable and function are passed as arguments to the map in Python.

    What does mapping mean in programming? ›

    It means matching items from one set with items in another set - or it means performing a function on each item in one set to get a new corresponding set. Which is kind of the same mathematically speaking. So it might mean matching tables in a database with objects in code.

    What does mapping mean in drawing? ›

    A mapping shows how the elements are paired. Its like a flow chart for a function, showing the input and output values. A mapping diagram consists of two parallel columns. The first column represents the domain of a function , and the other column for its range.

    What is mapping in matrix? ›

    This mapping matrix is formed using the fact that there is a wheel in each primary axis, and the fourth column is all zeros because there is no fourth wheel available. The mapping matrix A for the standard four-wheel configuration is defined as. (9.38) A = [ 1 0 0 − c β s α 0 1 0 − c β c α 0 0 1 s β ]

    Top Articles
    Latest Posts
    Article information

    Author: Carlyn Walter

    Last Updated:

    Views: 6136

    Rating: 5 / 5 (70 voted)

    Reviews: 93% of readers found this page helpful

    Author information

    Name: Carlyn Walter

    Birthday: 1996-01-03

    Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

    Phone: +8501809515404

    Job: Manufacturing Technician

    Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

    Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.