File Exchange

## geographiclib

version 1.49 (80.9 KB) by

MATLAB implementations of a subset of the C++ library, GeographicLib

Updated

GeographicLib toolbox
Version 1.49 2017-10-05
This toolbox provides native 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 ellipses: direct, inverse, area calculations.

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

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

Subsets of this package were previously released as:

Geodesics on an ellipsoid of revolution (deprecated)
Geodesic projections for an ellipsoid (withdrawn)
Great ellipses (withdrawn)

Including all of the functionality in a single toolbox allows easier
sharing of code (via a common private directory).

Extensive documentation on the C++ library is available at

Geoid lookup requires the installation of one or more geoid models.
Instructions for this are given in

A change log for this package is available at

Charles Karney

### Charles Karney (view profile)

help geocent_fwd says that lat and lon should be in degrees!
[X,Y,Z] = geocent_fwd(37.0328,15.065,370)
X = 4922883.48104775
Y = 1325070.28306503
Z = 3820522.46838327

To get the direction relative to one of the stations, you
should use loccart_fwd instead of geocent_fwd.

BlueEyes

### BlueEyes (view profile)

Good! Some discrepancies arise between this output coming from your drift
----------------------
>> format long g
>> h=370.0;
>> [X,Y,Z]= geocent_fwd(lat,lon,h)
X = 6378036.70547581
Y = 29269.4077049027
Z = 71471.7403795619
and the following coming from https://www.ngs.noaa.gov/cgi-bin/Inv_Fwd/invers3d.prl with results been att'd previously [sendspace works properly, click twice instead] and copied below (1^st station only)
First Station : CB
X = 4922883.4811 m LAT = 37 1 58.08000 North
Y = 1325070.2831 m LON = 15 3 54.00000 East
Z = 3820522.4683 m EHT = 370.0000 Meters
----------
Cheers

Charles Karney

### Charles Karney (view profile)

The sendspace link seems to require that I create an account and provide an E-mail.
I'm not prepared to do this. So please figure out another way of sending me images.

If you want the Euclidean distance between 2 points you can just convert them to
geocentric coordinates with geocent_fwd and then use Pythagoras.

BlueEyes

### BlueEyes (view profile)

geoddistance enhancement proposal: mark-to-mark distance btw. two earth stations, like shown here:
https://www.sendspace.com/file/i5sg1u
Is it possible to do it and link here? Or, alternatively, to show (X,Y,Z) rectangular coords algorithm?

BlueEyes

### BlueEyes (view profile)

Oh yes! It works properly now, the function becomes:
---------
function n = GeodSolve59
% Check for points close with longitudes close to 180 deg apart.
n = 0;
[s12, azi1, azi2] = geoddistance(5, 0.00000000000001, 10, 180);
n = n + assertEquals(azi1, 0.000000000000035, 1.5e-14);
n = n + assertEquals(azi2, 179.99999999999996, 1.5e-14);
n = n + assertEquals(s12, 18345191.174332713, 5e-9);
end
---------

Charles Karney

### Charles Karney (view profile)

@BlueEyes You are misinterpreting the patch file. The rule is remove the lines beginning
with "-" and replace them with the lines beginning with "+" (but with the "+" removed).
(Basically, the delta in the s12 test is changed from 2.5e-9 to 5e-9.)

BlueEyes

### BlueEyes (view profile)

Screenshot of the code amended
---------
https://www.sendspace.com/file/5nr3nm
---------

BlueEyes

### BlueEyes (view profile)

My GNU Octave 4.0.0 package still fails, as follows:
-----
>> geographiclib_test
parse error near line 458 of file C:\Training\z_geodesia\karney\geographiclib_test.m

invalid left hand side of assignment

>>> - n = n + assertEquals(s12, 18345191.174332713, 2.5e-9);
-------
Cheers

Charles Karney

### Charles Karney (view profile)

This patch to geographiclib_test.m fixes the problem reported by BlueEyes (it relaxes
one of the tests slightly):

diff --git a/matlab/geographiclib/geographiclib_test.m b/matlab/geographiclib/geographiclib_test.m
--- a/matlab/geographiclib/geographiclib_test.m
+++ b/matlab/geographiclib/geographiclib_test.m
@@ -457,7 +457,7 @@ function n = GeodSolve59
[s12, azi1, azi2] = geoddistance(5, 0.00000000000001, 10, 180);
n = n + assertEquals(azi1, 0.000000000000035, 1.5e-14);
n = n + assertEquals(azi2, 179.99999999999996, 1.5e-14);
- n = n + assertEquals(s12, 18345191.174332713, 2.5e-9);
+ n = n + assertEquals(s12, 18345191.174332713, 5e-9);
end

function n = GeodSolve61

BlueEyes

### BlueEyes (view profile)

Just sent the reply via email. Cheers

Charles Karney

### Charles Karney (view profile)

Reply to @BlueEyes: This may be a problem with the version of Matlab you
are used or the platform on which it is being run. Please could you run
the following in your version of Matlab (or Octave) to help me diagnose
the problem:

ver
[s12, azi1, azi2] = geoddistance(5, 0.00000000000001, 10, 180);
fprintf('%.10f %.15f %.15f\n', s12, azi1, azi2)

and provide the results to me (E-mail is preferred:
charles@karney.com). Thanks.

BlueEyes

### BlueEyes (view profile)

Please, be noticed of this drawback:
--------
1..
>> geographiclib_test
GeodSolve59 fail: 1
error: assert (n == 0) failed
error: called from
assert at line 92 column 11
geographiclib_test at line 56 column 3

2.. by eliminating the corresponding row, the test is successful:
% i = GeodSolve59; if i, n=n+1; fprintf('GeodSolve59 fail: %d\n', i); end
>> geographiclib_test
>>
--------
Cheers

John

### John (view profile)

Fantastic!! I have used geographiclib in Python and am very pleased it is now implemented in MATLAB.

Zhao Dejun

Charles Karney

### Charles Karney (view profile)

There's an obscure bug in geodreckon in calculating the area when an empty distance argument is given. A patch is provided in

https://sourceforge.net/p/geographiclib/news/2017/03/bug-in-matlab-function-geodreckon/

This will be included in the next release.

Bill Tandy

### Bill Tandy (view profile)

Exactly what I was looking for! Thank you!

Guy

Charles Karney

### Charles Karney (view profile)

The update to version 1.44 on 2015-08-14 caused a bug in geoddistance,
when it is used in Octave (not MATLAB) and is invoked with vector
arguments including nearly antipodal pairs of points on the equator.

This will be included in the next release.

Matthew

Chen Qiang

Great!