A Mapping package for Matlab (2024)

A Mapping package for Matlab (1)

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

But you can't.

Instead you have to figure out how to save all your data, and then read it intoanother program (like, for example GMT ),and then spend all that extra timefiguring out why it doesn't give you whatyou expected it would...

No more!

Announcing M_Map v1.3e!

M_Map is a set of mapping tools written for Matlab v5.These include:
  1. Routines to project data in 18 different spherical projections (and determineinverse mappings)
  2. A grid generation routine to make nice axes with limits either in lat/long termsor 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 and bathymetry databases

M_Map is now use at almost 1800 locations around the world!

A Mapping package for Matlab (2)

New in release 1.2 are

  1. Built-in functions for drawing lines, text, and quiver plots in long/lat coords
  2. Built-in functions for contouring data (filled and line contours) in long/lat coords
  3. Hooks into a 5-minute global bathymetry ( TerrainBase ) available from the net.
  4. Fancy quiver plots, thanks to E. Firing (see example 8)
  5. Gall-Peters projection (handy for large tropical areas)
  6. Fancy outline boxes! (see example 2 and example 6)
New in release 1.3 are
  1. High-resolution coastlines! (through hooks into the nested set of coastlinesat different resolutions making up the Global Self-consistent HierarchicalHigh-resolution Shoreline Database (GSHHS) used by GMT (see example 9)
  2. Instructions on how to use the new Sandwell and Smith bathymetry
  3. Hammer-Aitoff (example 11) and Mollweide projections (example 4)
New in release 1.3d are
  1. m_patch primitive
  2. m_scale primitive to allow drawing of maps at a required scale
  3. True elliptical UTM projection (thanks to P. Lemmond)
  4. m_track for drawing tracklines with time/date annotation (thanks to P. Lemmond)(example 10)
  5. m_plotbndry - hooks into an online database of political boundaries (Thanks to M. Mann)
New in release 1.3e are
  1. m_range_rings primitive to draw range rings (just great for nuclear weapon destructionradii and seismic travel-time data - see example 11).
  2. Extended usefullness of m_ungrid to allow removal of any specific plot element bya command line option.

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). Both arearound 250k in size. Once you have this archive, read the Getting started section of the User's guide tocorrectly install this toolbox, and sections 9and 10.1 to install TerrainBase and GSHHSrespectively.

A number of examples have been given to highlight thevarious capabilities of M_Map.

User's guide

  1. Getting started
  2. Specifying projections
    1. Azimuthal projections
    2. Cylindrical and Pseudo-cylindrical projections
    3. Conic projections
    4. Miscellaneous global projections
    5. Yeah, but which projection should I use?
    6. Map scales A Mapping package for Matlab (3)
  3. Coastlines and Bathymetry
    1. Coastline options
    2. Topography/Bathymetry options
  4. Customizing the axes
    1. Grid lines and labels
    2. Titles and x/ylabels
  5. Adding your own data
    1. Drawing lines, text, arrows, patches and contours
    2. Drawing tracklines A Mapping package for Matlab (4)
    3. Drawing range rings A Mapping package for Matlab (5)
    4. Converting longitude/latitude to projection coordinates
    5. Converting projection coordinates to longitude/latitude
  6. More complex plots
  7. Removing data from a plotA Mapping package for Matlab (6)
  8. Adding your own coastlines
    1. DCW political boundaries A Mapping package for Matlab (7)
  9. Adding your own topography/bathymetry
    1. Sandwell and Smith Bathymetry
  10. Using TerrainBase 5-minute global bathymetry/topography
  11. Using the GSHHS high-resolution coastline database
    1. Installing GSHHS
    2. Using GSHHS effectively
  12. M_Map toolbox contents and description
  13. Known Problems and Bugs
  14. Changes since last release A Mapping package for Matlab (8)
For information, help, suggestions, or bug reports, contact Rich Pawlowicz , ( rich@ocgy.ubc.ca )

Examples

1. M_Map Logo

m_proj('ortho','lat',48','long',-123');m_coast('patch','r');m_grid('linest','-','xticklabels',[],'yticklabels',[]);patch(.55*[-1 1 1 -1],.25*[-1 -1 1 1]-.55,'w');text(0,-.55,'M\_Map','fontsize',25,'color','b',... 'vertical','middle','horizontal','center');set(gcf,'units','inches','position',[2 2 3 3]);set(gcf,'paperposition',[3 3 3 3]);
A Mapping package for Matlab (9)

2. Lambert Conformal Conic projection of North American Topography

m_proj('lambert','long',[-160 -40],'lat',[30 80]);m_coast('patch',[1 .85 .7]);m_elev('contourf',[500:500:6000]);m_grid('box','fancy','tickdir','in');colormap(flipud(copper));
A Mapping package for Matlab (10)

3. Stereographic projection of North Polar regions

% Note that coastline is drawn OVER the grid because of the order in which% the two routines are calledm_proj('stereographic','lat',90,'long',30,'radius',25);m_elev('contour',[-3500:1000:-500],'edgecolor','b');m_grid('xtick',12,'tickdir','out','ytick',[70 80],'linest','-');m_coast('patch',[.7 .7 .7],'edgecolor','r');
A Mapping package for Matlab (11)

4. Two Interrupted Projections of the World's Oceans

subplot(211);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, m_proj('sinusoidal','long',Slongs(l,:),'lat',Slats(l,:)); m_grid('fontsize',6,'xticklabels',[],'xtick',[-180:30:360],... 'ytick',[-80:20:80],'yticklabels',[],'linest','-','color',[.9 .9 .9]); m_coast('patch','g');end;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:set(gca,'xlimmode','auto','ylimmode','auto');subplot(212);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_proj('mollweide','long',Slongs(l,:),'lat',Slats(l,:)); m_grid('fontsize',6,'xticklabels',[],'xtick',[-180:30:360],... 'ytick',[-80:20:80],'yticklabels',[],'linest','-','color','k'); m_coast('patch',[.6 .6 .6]);end;xlabel('Interrupted Mollweide Projection of World Oceans');set(gca,'xlimmode','auto','ylimmode','auto');
A Mapping package for Matlab (12)

5. Oblique Mercator Projection with quiver and contour data

%% Nice looking data[lon,lat]=meshgrid([-136:2:-114],[36:2:54]);u=sin(lat/6);v=sin(lon/6);m_proj('oblique','lat',[56 30],'lon',[-132 -120],'aspect',.8);subplot(121);m_coast('patch',[.9 .9 .9],'edgecolor','none');m_grid('tickdir','out','yaxislocation','right',... 'xaxislocation','top','xlabeldir','end','ticklen',.02);hold on;m_quiver(lon,lat,u,v);xlabel('Simulated surface winds');subplot(122);m_coast('patch',[.9 .9 .9],'edgecolor','none');m_grid('tickdir','out','yticklabels',[],... 'xticklabels',[],'linestyle','none','ticklen',.02);hold on;[cs,h]=m_contour(lon,lat,sqrt(u.*u+v.*v));clabel(cs,h,'fontsize',8);xlabel('Simulated something else');
A Mapping package for Matlab (13)

6. Miller Projection with Great Circle

% Plot a circular orbitlon=[-180:180];lat=atan(tan(60*pi/180)*cos((lon-30)*pi/180))*180/pi;m_proj('miller','lat',82);m_coast('color',[0 .6 0]);m_line(lon,lat,'linewi',3,'color','r');m_grid('linestyle','none','box','fancy','tickdir','out');
A Mapping package for Matlab (14)

7. Lambert Conformal Projection with high-resolution bathymetry of Western Mediterranean

m_proj('lambert','lon',[-10 20],'lat',[33 48]);m_tbase('contourf');m_grid('linestyle','none','tickdir','out','linewidth',3);
A Mapping package for Matlab (15)

8. Demonstration of fancy vectors

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

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.clfaxes('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_grid('linest','none','linewidth',2,'tickdir','out','xaxisloc','top','yaxisloc','right');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_grid('linest','none','linewidth',2,'tickdir','out','xaxisloc','top');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_grid('linest','none','linewidth',2,'tickdir','out');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_grid('linest','none','linewidth',2,'tickdir','out','yaxisloc','right');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_grid('linest','none','linewidth',2,'tickdir','out','xaxisloc','top','yaxisloc','right');m_text(-64.18,46.58,'GSHHS\_H (high)','color','m','fontweight','bold','fontsize',14);
A Mapping package for Matlab (17)

10. Tracklines and UTM projection

m_proj('UTM','long',[-72 -68],'lat',[40 44]);m_gshhs_i('color','k');m_grid('box','fancy','tickdir','in');% fake up a tracklinelons=[-71:.1:-67];lats=60*cos((lons+115)*pi/180);dates=datenum(1997,10,23,15,1:41,zeros(1,41));m_track(lons,lats,dates,'ticks',0,'times',4,'dates',8,... 'clip','off','color','r','orient','upright'); 
A Mapping package for Matlab (18)

11. Range rings

 m_proj('hammer','clong',170); m_grid('xtick',[],'ytick',[],'linestyle','-'); m_coast('patch','g'); m_line(100.5,13.5,'marker','square','color','r'); m_range_ring(100.5,13.5,[1000:1000:15000],'color','b','linewi',2); xlabel('1000km range rings from Bangkok');
A Mapping package for Matlab (19)

Last changed 18/Dec/1998. Questions and comments to rich@ocgy.ubc.ca
A Mapping package for Matlab (2024)

FAQs

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 Geoplot toolbox in MATLAB? ›

Mapping Toolbox™ extends the functionality of the geoplot (MATLAB®) function. It adds support for displaying points, lines, and polygons with coordinates in any supported geographic or projected coordinate reference system (CRS). Depending on the type of axes, the function displays data into different map projections.

How to make maps 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.

How to load a map in MATLAB? ›

Download it from the File Exchange site, place borders. m in your current Matlab folder, and the code above should work. You do not need the Mapping Toolbox to use the borders function.

What is the Colormap toolbox in MATLAB? ›

The Choose Colormap tool is an interactive colormap selection tool that allows you to change the colormap of a figure by selecting a colormap from a list of MATLAB® colormap functions or workspace variables, or by entering a custom MATLAB expression.

What is a MATLAB toolbox? ›

The toolbox is a collection of functions built on the MATLAB® technical computing environment. You can use the toolbox to: Connect to CAN Devices. Use Supported CAN Devices and Drivers.

How to create a 3D map in MATLAB? ›

To plot a 3D surface from a data file in MATLAB, you will need to have the data file open in MATLAB. Once you have the data file available, you can use the plot3 command to plot the data. The plot3 command will create a 3D plot of the data. You can also use the surf command to create a 3D surface plot.

Can I make my own map? ›

Create a map

On your computer, sign in to My Maps. Click Create a new map. Go to the top left and click "Untitled map." Give your map a name and description.

How to plot contour maps in MATLAB? ›

To draw the contour lines at specific heights, specify levels as a vector of monotonically increasing values. To draw the contours at one height ( k ), specify levels as a two-element row vector [k k] . contour(___, LineSpec ) specifies the style and color of the contour lines.

How do you make a good plot in MATLAB? ›

Direct link to this comment
  1. Increase the linewidth (2 or 3 is good).
  2. Add a grid.
  3. Add minor ticks to the axes.
  4. Plot as an area with solid line and semi-transparent fill.
  5. Set the axes limits appropriately.
  6. Add a legend.
  7. Change the font and fontsize to match the output size.
  8. Set the figure aspect ratio correctly.
Feb 27, 2016

What is the map function in MATLAB? ›

A map function basically takes the elements of the array and applies a function to each element. The resultant output is of the same shape as the array, but the values are the result of the function.

How to add basemap in MATLAB? ›

You can also add a basemap picker to the axes toolbar by using the Mapping Toolbox™ function addToolbarMapButton (Mapping Toolbox). MATLAB® includes one installed basemap, a two-tone map named 'darkwater' . Use of this basemap does not require internet access.

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? ›

However, for what you see here in regards to functional programming, mapping refers to a process of applying a high-order function to each member of a list. Because the function is applied to every member of the list, the relationships among list members is unchanged.

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? ›

The simplest example of a matrix mapping is given by matrices. Matrix mappings defined from are where is a real number. Note that the graph of this function is just a straight line through the origin (with slope ). From this example we see that matrix mappings are very special mappings indeed.

Top Articles
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 6132

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.