Skip to content

geographiclib/geographiclib-octave

Repository files navigation

Octave/MATLAB implementation of GeographicLib

Contents:

Introduction

This toolbox provides native Octave/MATLAB implementations of a subset of the C++ library, GeographicLib. Key components of this toolbox are

  • Geodesics, direct, inverse, area calculations.
  • Projections, transverse Mercator, polar stereographic, etc.
  • Grid systems, UTM, UPS, MGRS.
  • Geoid lookup, egm84, egm96, egm2008 geoids supported.
  • Geometric transformations, geocentric, local cartesian.
  • Great ellipse, direct, inverse, area calculations.
  • Geodesics and coordinate conversions on a triaxial ellipsoid.

(The last two items are not present in the C++ library.) All the functions are vectorized and so offer speeds comparable to compiled C++ code when operating on arrays.

Some common features of these functions:

  • Angles (latitude, longitude, azimuth, meridian convergence) are measured in degrees.
  • Distances are measured in meters, areas in meters^2.
  • Latitudes must lie in [-90, 90]. Latitudes outside this range are treated in NaNs
  • The ellipsoid is specified as [a, e], where a = equatorial radius and e = eccentricity. The eccentricity can be pure imaginary to denote a prolate ellipsoid.
  • Keep |e| < 0.2 (i.e., |f| <= 1/50) for full double precision accuracy.

There is some overlap between this toolbox and MATLAB's Mapping Toolbox. However, this toolbox offers:

  • better accuracy;
  • treatment of oblate and prolate ellipsoid;
  • guaranteed convergence for geoddistance;
  • calculation of area and differential properties of geodesics;
  • ellipsoidal versions of the equidistant azimuthal and gnomonic projections.

Licensed under the MIT/X11 License; see LICENSE.txt.

Installation

The toolbox is available from

  • SourceForge This includes packages for Octave, geographiclib-octave-M.N.tar.gz, and MATLAB, geographiclib_toolbox-M.N.mltbx. Here M.N stands for the version number, e.g., 2.0. The Octave and MATLAB packages contain exactly the same code; it's just the packaging that is different.

  • Octave Packages. This links to the SourceForge download site.

  • MATLAB Central. You need to log in to download packages from here. Use SourceForge (see above) if you don't have an account.

Octave installation

Either download the package to your computer and install it in Octave with the commands

pkg install geographiclib-octave-M.N.tar.gz
pkg load geographiclib

Or you can have Octave download and install the package with the commands

pkg install "https://sourceforge.net/projects/geographiclib/files/distrib-Octave/geographiclib-octave-M.N.tar.gz"
pkg load geographiclib

NOTE: in both cases replace M.N by the version number.

Other useful Octave package commands

pkg list                            % list all packages
ver geographiclib                   % list version
pkg describe -verbose geographiclib % list functions
news geographiclib                  % change log
pkg test geographiclib              % run the tests
pkg unload geographiclib            % remove from path
pkg uninstall geographiclib         % uninstall

MATLAB installation

The MATLAB toolbox can be installed via the "Add-Ons" menu item with MATLAB. Alternatively, it can be installed by downloading the package from SourceForge (see above) and using the command

matlab.addons.install geographiclib_toolbox-M.N.mltbx

NOTE: replace M.N by the version number.

Other useful MATLAB toolboxes commands

t = matlab.addons.installedAddons        % list all toolboxes
n = 1;                                   % the row with geographiclib
matlab.addons.uninstall(t.Identifier(n)) % uninstall

Function summary

Geodesics

  • geoddistance - Distance between points on an ellipsoid
  • geodreckon - Point at specified azimuth, range on an ellipsoid
  • geodarea - Surface area of polygon on an ellipsoid

Projections

Grid systems

Geoid lookup

Geometric transformations

  • geocent_fwd - Conversion from geographic to geocentric coordinates
  • geocent_inv - Conversion from geocentric to geographic coordinates
  • loccart_fwd - Convert geographic to local cartesian coordinates
  • loccart_inv - Convert local cartesian to geographic coordinates

Great ellipses

  • gedistance - Great ellipse distance on an ellipsoid
  • gereckon - Point along great ellipse at given azimuth and range

Utility

Documentation

  • geoddoc - Geodesics on an ellipsoid of revolution
  • projdoc - Projections for an ellipsoid
  • gedoc - Great ellipses on an ellipsoid of revolution

The class for triaxial ellipsoids

See also Implementation details for details of some of the algorithms used here.

Changes

See the change log. Releases are tagged in git as, e.g., v1.52, v2.0, etc.

Other links