Main Content


Equally spaced waypoints along great circle


[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2)
[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2,nlegs)
pts = gcwaypts(lat1,lon1,lat2,lon2...)


[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2) returns the coordinates of equally spaced points along a great circle path connecting two endpoints, (lat1,lon1) and (lat2,lon2).

[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2,nlegs) specifies the number of equal-length track legs to calculate. nlegs+1 output points are returned, since a final endpoint is required. The default number of legs is 10.

pts = gcwaypts(lat1,lon1,lat2,lon2...) packs the outputs, which are otherwise two-column vectors, into a two-column matrix of the form [latitude longitude]. This format for successive waypoints along a navigational track is called navigational track format in this guide. See the navigational track format reference page in this section for more information.


This is a navigational function. It assumes that all latitudes and longitudes are in degrees.

In navigational practice, great circle paths are often approximated by rhumb line segments. This is done to come reasonably close to the shortest distance between points without requiring course changes too frequently. The gcwaypts function provides an easy means of finding waypoints along a great circle path that can serve as endpoints for rhumb line segments (track legs).


collapse all

Imagine you own a sailing yacht and are planning a voyage from North Point, Barbados (13.33° N,59.62°W), to Brest, France (48.36°N,4.49°W). Divide the track into three equal-length segments.

ha = axesm('mapproj','mercator',...
    'maplatlim',[10 55],'maplonlim',[-80 10],...
axis off, gridm on, framem on;
% Load coastline data and plot it in the figure.
load coastlines;
hg = geoshow(coastlat,coastlon,'displaytype','line','color','b');
% Define point locations for Barbados and Brest
barbados = [13.33 -59.62];
brest = [48.36 -4.49];
% Calculate the waypoints along the path.
[l,g] = gcwaypts(barbados(1),barbados(2),brest(1),brest(2),3);

Version History

Introduced before R2006a

See Also

| | |