This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Display map latitude and longitude data


h = geoshow(___)


geoshow(lat,lon) projects and displays the latitude and longitude vectors lat and lon using the projection stored in the axes. If there is no projection, lat and lon are projected using a default Plate Carrée projection. The default behavior for geoshow is to display lat and lon as lines.

geoshow(S) displays the vector geographic features stored in S as points, multipoints, lines, or polygons according to the 'Geometry' field of S. If S is either a geopoint vector, a geoshape vector, or a geostruct (with 'Lat' and 'Lon' coordinate fields), geoshow projects vertices to map coordinates. If S is either a mappoint vector, mapshape vector, or a mapstruct (with 'X' and 'Y' fields), geoshow plots vertices as (pre-projected) map coordinates and issues a warning.

geoshow(lat,lon,Z) projects and displays a geolocated data grid.

geoshow(Z,R) projects and displays a regular data grid, Z.

geoshow(lat,lon,image) or geoshow(lat,lon,A,cmap) projects and displays a geolocated image as a texturemap on a zero-elevation surface. lat, lon, and the image array must match in size. Examples of geolocated images include a color composite from a satellite swath or an image originally referenced to a different coordinate system.

geoshow(image,R) or geoshow(A,cmap,R) projects and displays an image georeferenced to latitude-longitude through the referencing matrix R. The image is shown as a texturemap on a zero-elevation surface.

geoshow(filename) projects and displays data from the file specified according to the type of file format.

geoshow(___,Name,Value,...) specifies parameters and corresponding values that modify the type of display or set MATLAB® graphics properties. Parameter names can be abbreviated, and case does not matter.

geoshow(ax,___) set the parent axes to ax.

h = geoshow(___) returns a handle to a MATLAB graphics object.

Input Arguments


Latitude vector. The vectors may contain embedded NaNs to delimit individual lines or polygon parts. lat must be of equal length to lon.


Longitude vector. The vectors may contain embedded NaNs to delimit individual lines or polygon parts. lon must be of equal length to lat.


M-by-N array. May contain NaN values.


Geographic data structure or dynamic vector


Grayscale, logical, or truecolor image.


Indexed image.




Geographic raster reference object, referencing vector, or referencing matrix. If R is a geographic raster reference object, its RasterSize property must be consistent with size(Z).

If R is a referencing vector, it must be a 1-by-3 with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

If R is a referencing matrix, it must be 3-by-2 and transform raster row and column indices to or from geographic coordinates according to:

[lon lat] = [row col 1] * R

If R is a referencing matrix, it must define a (non-rotational, non-skewed) relationship in which each column of the data grid falls along a meridian and each row falls along a parallel. Nearest-neighbor interpolation is used by default. NaN is returned for points outside the grid limits or for which lat or lon contain NaN. All angles are in units of degrees.

If R is a geographic raster reference object with raster interpretation 'postings', then the 'image' and 'texturemap' display types are not accepted.


Axes object.


Name of file.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.


A structure returned by makesymbolspec that specifies the symbolization rules to be used for displaying vector data. It is used only for vector data stored in geographic data structures. In cases where both SymbolSpec and one or more graphics properties are specified, the graphics properties override any settings in the symbolspec structure.

To change the default symbolization rule for a Name,Value pair in the symbolspec, prefix the word 'Default' to the graphics property name.


Type of graphic display for the data. You can set any MATLAB Graphics line, patch, and surface properties. You can also set any Mapping Toolbox™ contour properties. See the table for links to the documentation on these properties.

Data TypeDisplayTypeType of Property



line marker


line marker

'line' (default)
















If DisplayType is 'texturemap', geoshow constructs a surface with ZData values set to 0.

When using the filename argument, the DisplayType parameter is automatically set, according to the following table:



Shape file

'point', 'line', or 'polygon'



TIFF/JPEG/PNG with a world file



'surface' (can be overridden)

SDTS raster

'surface' (can be overridden)

Output Arguments


Handle to a MATLAB graphics object or, in the case of polygons, a modified patch object. If a geostruct or shapefile name is input, geoshow returns the handle to an hggroup object with one child per feature in the geostruct or shapefile, excluding any features that are completely trimmed away. In the case of a polygon geostruct or shapefile, each child is a modified patch object; otherwise it is a line object.

Class Support

Display TypeSupported Class Types
Imagelogical, uint8, uint16, and double
Surfacesingle and double
Texture mapAll numeric types and logical


collapse all

Display map of the world using default Plate Carree projection.

geoshow('landareas.shp', 'FaceColor', [0.5 1.0 0.5]);

Set up an empty map axes with projection and limits suitable for displaying all 50 states.


Read USA high resolution data.

states = shaperead('usastatehi', 'UseGeoCoords', true);

Create a symbolspec that sets the color of Alaska and Hawaii polygons red.

symspec = makesymbolspec('Polygon', ...
   {'Name', 'Alaska', 'FaceColor', 'red'}, ...
   {'Name', 'Hawaii', 'FaceColor', 'red'});

Display all the other states, setting the default FaceColor property to blue and the default EdgeColor property to black.

geoshow(states, 'SymbolSpec', symspec, ...
   'DefaultFaceColor', 'blue', ...
   'DefaultEdgeColor', 'black');

Display a map, using the geoshow function with the 'DisplayType' parameter set to 'TextureMap' .

Load MAT file containing map information about Korean peninsula.

load korea

Set up an empty map axes with projection and limits for the Korean peninsula.

worldmap(map, refvec)

Display the Korean data grid as a texture map.


Display the land area boundary as a black line.

S = shaperead('landareas','UseGeoCoords',true);
geoshow([S.Lat], [S.Lon],'Color','black');

Display a map, interpreting NaNs as transparent. This example uses the geoshow function with the 'DisplayType' parameter set to 'surface' .

Load map of Korean peninsula.

korea = load('korea');
Z =;

Insert an band of null values using NaNs.

Z(80:100,:) = NaN;

Create a raster reference object.

R = georasterref('RasterSize',size(Z),...
    'Latlim',[30 45], 'Lonlim', [115 135]);

Display world map with NaN values displayed as transparent. Note that the settings for ZData and CData ensure that the resulting surface falls in the z == 0 plane, instead of being 3-dimensional.


Load geoid and display.

load geoid

Create a figure with an Eckert projection.

axesm eckert4; 
framem; gridm;
axis off

Display the geoid as a texture map.

geoshow(geoid, geoidrefvec, 'DisplayType', 'texturemap');

Create a colorbar and title.

hcb = colorbar('southoutside');
set(get(hcb,'Xlabel'),'String','EGM96 Geoid Heights in Meters.')

Mask out all the land.

geoshow('landareas.shp', 'FaceColor', 'black');

Create the figure with an Eckert projection.

axesm eckert4
axis off

Load the geoid, and display it as a surface.

load geoid
h = geoshow(geoid, geoidrefvec, 'DisplayType','surface');

Add light and material.

material(0.6*[ 1 1 1])

View the map as a 3-D surface.

axis normal

Load the moon albedo image.

load moonalb

Project and display the moon albedo image using a default Plate Carree projection.


Project and display the moon albedo image as a texture map in an orthographic projection.

axesm ortho 
axis off

Unzip a USGS 24K digital elevation model (DEM) file into a temporary file. The toolbox includes a San Francisco South 24K DEM file.

filenames = gunzip('sanfranciscos.dem.gz',tempdir); 
demFilename = filenames{1}; 

Read every other point of the 1:24,000 DEM file.

[lat,lon,Z,header,profile] = usgs24kdem(demFilename,2);

Delete the temporary file.


Because no negative elevations exist, move all points at sea level to -1 to color them blue.

Z(Z==0) = -1;

Compute the latitude and longitude limits for the DEM.

latlim = [min(lat(:)) max(lat(:))] 
latlim = 

   37.6249   37.7504

lonlim = [min(lon(:)) max(lon(:))]
lonlim = 

 -122.5008 -122.3740

Display the DEM values as a texture map.

usamap(latlim, lonlim)
geoshow(lat, lon, Z, 'DisplayType','texturemap')

Overlay black contour lines onto the texture map.

geoshow(lat,lon,Z,'DisplayType','contour', ...

View the DEM values in 3-D.

usamap(latlim, lonlim)


  • When calling shaperead to read files that contain coordinates in latitude and longitude, be sure to specify the shaperead argument pair 'UseGeoCoords',true. If you do not include this argument, shaperead will create a mapstruct, with coordinate fields labelled X and Y instead of Lon and Lat. In such cases, geoshow assumes that the geostruct is in fact a mapstruct containing projected coordinates, warns, and calls mapshow to display the geostruct data without projecting it.

  • If you do not want geoshow to draw on top of an existing map, create a new figure or subplot before calling it.

  • When you display vector data in a map axes using geoshow, you should not subsequently change the map projection using setm. You can, however, change the projection with setm for raster data. For more information, see Change Map Projections when Using geoshow.

  • If you display a polygon, do not set 'EdgeColor' to either 'flat' or 'interp'. This combination may result in a warning.

  • When projecting data onto a map axes, geoshow uses the projection stored with the map axes. When displaying on a regular axes, it constructs a default Plate Carrée projection with a scale factor of 180/pi, enabling direct readout of coordinates in degrees.

  • geoshow can generally be substituted for displaym. However, there are limitations where display of specific objects is concerned. See the remarks under updategeostruct for further information.

When you display raster data in a map using geoshow, columns near the eastern or western edge may fail to display. This is seldom noticeable, except when the raster is very coarse relative to the displayed area. To include additional columns in the display, it might help to:

  • Resize the grid to a finer mesh

  • Make sure the cell boundaries and map limits align

  • Expand the map limits

Introduced before R2006a

Was this topic helpful?