Geographic globe plot
geoplot3(___,
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.Name,Value
)
p = geoplot3(___)
returns a Line
object. This syntax is useful for controlling the properties of the line.
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')
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)
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)
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');
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';
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)
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)
g
— Geographic globeGeographicGlobe
objectGeographic globe, specified as a GeographicGlobe
object.[1]
lat
— Geodetic latitudesGeodetic latitudes in degrees, specified as a vector.
lat
and lon
must be the same size.
Data Types: single
| double
lon
— Geodetic longitudesGeodetic longitudes in degrees, specified as a vector.
lat
and lon
must be the same size.
Data Types: single
| double
h
— HeightsHeights 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
LineSpec
— Line style, marker, and colorLine 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 Marker | Description |
---|---|
- | Solid line (default) |
o | Circle marker |
Color | Description |
---|---|
| yellow |
| magenta |
| cyan |
| red |
| green |
| blue |
| white |
| black |
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
.
geoplot3(g,1:10,1:10,1:10,'Color','r')
changes the color of
the lineNote
The properties listed here are only a subset. For a full list, see Line Properties.
'HeightReference'
— Height reference'geoid'
(default) | 'terrain'
| 'ellipsoid'
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.
'Color'
— Line color[0 0 0]
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...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 Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
'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 applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[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'
'LineStyle'
— Line style'-'
(default) | 'none'
Line style, specified as one of these options:
Line Style | Description | Resulting Line |
---|---|---|
'-' | Solid line (default) |
|
'none' | No line | No line |
'Marker'
— Marker symbol'none'
(default) | 'o'
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.
Unlike most Line
objects, lines created using
geoplot3
cannot have their parent changed to any object except a
geographic globe.
[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®.