Access Basemaps in MATLAB

MathWorks® offers a selection of basemaps for use with geographic axes and charts. The basemaps provide a variety of map options, including two-tone, color terrain, high-zoom-level street, and high-zoom-level topographic displays. Six of the basemaps are tiled data sets that MathWorks derives from public-domain data. Five of the basemaps are high-zoom-level maps hosted by Esri®. For more information about basemap options, see the Basemap argument in geobasemap.

To specify a basemap for your geographic axes or chart, you can either:

  • Use the geobasemap function.

  • Set the Basemap property of the GeographicAxes or GeographicBubbleChart object.

MATLAB® includes one installed basemap, a two-tone map named 'darkwater'. Use of this basemap does not require Internet access. Use of the other basemaps, including the default basemap 'streets-light', does require Internet access.

If you do not have reliable access to the Internet, or want to improve map responsiveness, you can plot using the 'darkwater' basemap or download a selection of basemaps onto your local system.

Display 'darkwater' on Geographic Plots

To display the 'darkwater' basemap while plotting with functions such as geoplot and geoscatter, call geobasemap.

lat1 = [33.448 29.424 32.716 32.777 37.338];
lon1 = [-112.074 -98.494 -117.161 -96.797 -121.886];
geoscatter(lat1,lon1,'*')
geobasemap darkwater

Alternatively, you can create a set of geographic axes and specify the Basemap name-value pair. To maintain the basemap, use the hold on command before plotting.

figure
lat2 = [40.713 34.052 41.878 29.760 39.952];
lon2 = [-74.006 -118.244 -87.630 -95.370 -75.165];
geoaxes('Basemap','darkwater')
hold on
geoscatter(lat2,lon2,'*')

You can also change the default basemap for all plots created with geoplot, geoscatter, and geodensityplot during your MATLAB session.

set(groot,'defaultGeoaxesBasemap','darkwater')

Display 'darkwater' on Geographic Bubble Charts

To display 'darkwater' on a geographic bubble chart, call geobubble using the 'Basemap' name-value pair.

tsunamis = readtable('tsunamis.xlsx');
geobubble(tsunamis,'Latitude','Longitude','Basemap','darkwater');

Alternatively, you can specify the basemap by using geobasemap.

counties = readtable('counties.xlsx');
geobubble(counties,'Latitude','Longitude');
geobasemap darkwater

Download Basemaps

Download basemaps onto your local system using the Add-On Explorer. The five high-zoom-level basemaps provided by Esri are not available for download.

  1. On the MATLAB Home tab, in the Environment section, click Add-Ons > Get Add-Ons.

  2. In the Add-On Explorer, scroll to the MathWorks Optional Features section, and click show all to find the basemap packages. You can also search for the basemap add-ons by name (listed in the following table) or click Optional Features in Filter by Type.

  3. Select the basemap data packages that you want to download.

    Basemap NameBasemap Data Package Name
    'bluegreen'MATLAB Basemap Data - bluegreen
    'grayland'MATLAB Basemap Data - grayland
    'colorterrain'MATLAB Basemap Data - colorterrain
    'grayterrain'MATLAB Basemap Data - grayterrain
    'landcover'MATLAB Basemap Data - landcover

Basemap Caching Behavior

When you access a basemap over the Internet, MATLAB improves performance by temporarily caching the basemap tiles. With this caching behavior, the program has to download each tile only once as you pan and zoom within the map. If you lose your connection to the Internet, you can still view parts of the map that you have already viewed, because the map tiles are stored locally.

When you are not connected to the Internet and you attempt to view a part of the map that you have not previously viewed, tiles for these areas are not in your cache. For the basemaps hosted by MathWorks, the program replaces missing tiles with tiles from the 'darkwater' basemap.

For the high-zoom-level basemaps provided by Esri, the program caches a limited number of tiles and the cached tiles expire after a limited time. If you attempt to view a region of a high-zoom-level basemap that is not cached, you will see blank map tiles. The geographic chart does not use tiles from 'darkwater' for these missing tiles.

See Also

Functions

Properties

Related Topics