Main Content

geoplot3

Geographic globe plot

Description

example

geoplot3(g,lat,lon,h) plots a 3-D line in the geographic globe specified by g at the vertices specified by lat, lon, and h.

example

geoplot3(___,LineSpec) sets the line style, marker, and color.

example

geoplot3(___,Name,Value) specifies additional options for the line using one or more name-value pair arguments. Specify the options after all other input arguments. For a list of options, see Line Properties.

p = geoplot3(___) returns a Line object. This syntax is useful for controlling the properties of the line.

Examples

collapse all

Plot the path of a glider above a local region. First, import sample data representing the path. Get the latitude, longitude, and geoid height values.

trk = gpxread('sample_mixed','FeatureType','track');
lat = trk.Latitude;
lon = trk.Longitude;
h = trk.Elevation;

Create a geographic globe. Then, plot the path as a line. By default, the view is directly above the data. Tilt the view by holding Ctrl and dragging.

uif = uifigure;
g = geoglobe(uif);
geoplot3(g,lat,lon,h,'c')

A 3-D line plotted over a region with terrain imagery.

When you plot a line between points that are far apart, the data may be obscured because the line passes through the Earth. View the entire line by inserting points between the specified data points.

For example, specify the coordinates of New York City and Paris. Then, plot a line between them. Indicate there is no height data by specifying the fourth argument of geoplot3 as an empty array. Note that you cannot see the line because it passes through the Earth.

lat = [40.71 48.86];
lon = [-74.01 2.35];
uif = uifigure;
g = geoglobe(uif);
geoplot3(g,lat,lon,[],'y','LineWidth',2)

A globe displaying New York City and Paris. There is no visible line.

To see the line, insert points along a great circle using the interpm function. Then, plot the line again. Note that the line is visible.

[latI,lonI] = interpm(lat,lon,0.1,'gc');
geoplot3(g,latI,lonI,[],'y','LineWidth',2)

A globe with a yellow line between New York City and Paris. The entire line is visible.

When you plot a line over a large region such as a state or country, part of the line may be obscured because it passes through terrain. View the entire line by removing the terrain data from the globe.

For example, import sample coastline data and plot it on a geographic globe. By default, the globe includes terrain data derived from the GMTED2010 model. Note that the line appears broken.

load coastlines
uif = uifigure;
g = geoglobe(uif);
p = geoplot3(g,coastlat,coastlon,[],'m');

A globe with a magenta line along coastlines. The line appears broken.

To see the line, set the Terrain property of the globe to 'none'. Indicate the plotted data sits on the WGS84 reference ellipsoid by setting the HeightReference property of the line to 'ellipsoid'. Note that the line is visible over the basemap.

g.Terrain = 'none';
p.HeightReference = 'ellipsoid';

A globe with a cyan line along coastlines. The line is visible over the basemap.

Import sample data representing the path of a glider. Get the latitude, longitude, and geoid height values.

trk = gpxread('sample_mixed','FeatureType','track');
lat = trk.Latitude;
lon = trk.Longitude;
h = trk.Elevation;

Create a geographic globe. Then, plot the data using circle markers. Plot a marker at every 25th data point by setting the MarkerIndices property.

uif = uifigure;
g = geoglobe(uif);
mskip = 1:25:length(lat);
geoplot3(g,lat,lon,h,'co','MarkerIndices',mskip)

Circle markers plotted over a region with terrain imagery.

Plot a line from the surface of Gross Reservoir to a point above South Boulder Peak.

Specify the latitude, longitude, and height of the two endpoints. Specify the heights relative to the terrain, so that 0 represents ground level and not sea level.

lat = [39.95384 39.95];
lon = [-105.29916 -105.3608];
hTerrain = [10 0];

Plot the line on a geographic globe. Indicate that height values are referenced to the terrain using the HeightReference property. By default, the view is directly above the data. Tilt the view by holding Ctrl and dragging.

uif = uifigure;
g = geoglobe(uif);
geoplot3(g,lat,lon,hTerrain,'y','HeightReference','terrain', ...
    'LineWidth',3)

A 3-D line plotted from the surface of a reservoir to a point above a peak.

Input Arguments

collapse all

Geographic globe, specified as a GeographicGlobe object.[1]

Geodetic latitudes in degrees, specified as a vector.

lat and lon must be the same size.

Data Types: single | double

Geodetic longitudes in degrees, specified as a vector.

lat and lon must be the same size.

Data Types: single | double

Heights in meters, specified as a vector. By default, height values are referenced to the geoid, or mean sea level.

Reference height values to the WGS84 reference ellipsoid by setting the HeightReference property of the line to 'ellipsoid'. Reference height values to the terrain, or ground, by setting the HeightReference property to 'terrain'.

h must be either a scalar or a vector of the same size as lat and lon. If h is a scalar, then every point is plotted at the same height.

Data Types: single | double

Line style, marker, and color, specified as a character vector or string containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

Example: '-or' is a red solid line with circle markers

Line Style and MarkerDescription
-Solid line (default)
oCircle marker
ColorDescription

y

yellow

m

magenta

c

cyan

r

red

g

green

b

blue

w

white

k

black

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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: geoplot3(g,1:10,1:10,1:10,'Color','r') changes the color of the line

Note

The properties listed here are only a subset. For a full list, see Line Properties.

Height reference, specified as one of these values:

  • 'geoid' – Height values are relative to the geoid (mean sea level).

  • 'terrain' – Height values are relative to the ground.

  • 'ellipsoid' – Height values are relative to the WGS84 reference ellipsoid.

For more information about terrain, geoid, and ellipsoid height, see Find Ellipsoidal Height from Orthometric and Geoid Height.

Line color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of [0 0 0] corresponds to black.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Thus, the color codes '#FF8800', '#ff8800', '#F80', and '#f80' are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
'red''r'[1 0 0]'#FF0000'

'green''g'[0 1 0]'#00FF00'

'blue''b'[0 0 1]'#0000FF'

'cyan' 'c'[0 1 1]'#00FFFF'

'magenta''m'[1 0 1]'#FF00FF'

'yellow''y'[1 1 0]'#FFFF00'

'black''k'[0 0 0]'#000000'

'white''w'[1 1 1]'#FFFFFF'

'none'Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]'#0072BD'

[0.8500 0.3250 0.0980]'#D95319'

[0.9290 0.6940 0.1250]'#EDB120'

[0.4940 0.1840 0.5560]'#7E2F8E'

[0.4660 0.6740 0.1880]'#77AC30'

[0.3010 0.7450 0.9330]'#4DBEEE'

[0.6350 0.0780 0.1840]'#A2142F'

Example: 'blue'

Example: [0 0 1]

Example: '#0000FF'

Line style, specified as one of these options:

Line StyleDescriptionResulting Line
'-'Solid line (default)

'none'No lineNo line

Marker symbol, specified as 'none' or 'o'. By default, the line does not display markers. Specify 'o' to display circle markers at each data point or vertex.

Markers do not tilt or rotate as you navigate the globe.

Limitations

Unlike most Line objects, lines created using geoplot3 cannot have their parent changed to any object except a geographic globe.

Introduced in R2020a

[1] Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.