Julia interface

Julia interface functions

Note

The Julia-style interface with which you should normally interact with GeographicLib.jl uses coordinates in the order lon, lat. Note that the original library uses lat, lon order, which is opposite our convention.

Types and constructors

Geodesic

The Geodesic type defines an ellipsoid on which subsequent great circle calculations can be performed.

Geodesic(a, f) -> geodesic

Set up an ellipsoid for geodesic calculations. a is the semimajor radius of the ellipsoid, whilst flattening is given by f.

source

GeodesicLine

The GeodesicLine type includes an ellipsoid and defines a particular great circle on that ellipsoid.

Note

Calculating waypoints along a certain section of a GeodesicLine requires setting an endpoint when constructing it. Use either the lon2 and lat2 arguments, or azi and a distance (either dist or angle).

GeodesicLine([ellipsoid::Geodesic.WGS84,] lon1, lat1; azi, lon2, lat2, angle, dist)

Construct a GeodesicLine, which may be used to efficiently compute many distances along a great circle. Set the coordinates of the starting point lon1° and lat1°. There are two ways to define the great circle this way:

  1. Set a start point, azimuth, and optionally distance. This requires the keyword arguments azi1 (all °) and optionally either angle (angular distance, °) or distance dist (m).
  2. Set a start point and end point. This requires the keyword arguments lon2 and lat2 (all °).

If ellipsoid is not supplied, then WGS84 is used by default.

See forward and forward_deg for details of computing points along a GeodesicLine.

source

Polygon

The Polygon type holds many points on an ellipsoid and can be used to calculate the perimeter of a polygon or the area enclosed by it by call properties. Use add_point! or add_edge! to add points to a Polygon.

Polygon([ellipsoid::Geodesic=WGS84,] polyline=false)

Construct a Polygon, which contains a set of points on a certain ellipsoid.

With this construction, the Polygon contains no points.

If polyline is true, then the Polygon will not accumulate area and instead only its perimeter can be calculated.

source
Polygon([ellipsoid::Geodesic=WGS84,] lons, lat) -> polygon

Construct a polygon from arrays of coordinates lons and lats, optionally specifying an ellipsoid, which defaults to WGS84.

Calculate the polygon's area and perimeter with properties.

source

Functions

Geodesics and GeodesicLines

GeographicLib.forwardFunction.
forward([ellipsoid::Geodesic=WGS84,] lon, lat, azi, dist) -> lon′, lat′, baz, dist, angle

Compute the final position when travelling from longitude lon°, latitude lat°, along an azimuth of azi° for dist m (or whichever units the ellipsoid is defined using). The final coordinates are (lon′, lat′)°, the backazimuth from the final point to the start is baz°, and the angular distance is angle°.

If ellipsoid is not supplied, then WGS84 is used by default.

source
forward(a, f, lon, lat, azi, dist) -> lon′, lat′, baz, dist, angle

Compute the final point assuming an ellipsoid with semimajor axis a m and flattening f.

Note that precomputing the ellipsoid with Geodesic and then reusing this if multiple forward or forward_deg calculations are needed will be more efficient.

source
forward(line::GeodesicLine, dist) -> lon′, lat′, baz, dist, angle

Compute the final point when travelling along a pre-computed great circle line for a distance of dist m. angle is the angular distance in °.

source
forward_deg([ellipsoid::Geodesic=WGS84,] lon, lat, azi, angle) -> lon′, lat′, baz, dist, angle

Compute the final position when travelling from longitude lon°, latitude lat°, along an azimuth of azi° for an angular distance of angle°. The final coordinates are (lon′, lat′)°, the backazimuth from the final point to the start is baz°, and the distance is dist m.

If ellipsoid is not supplied, then WGS84 is used by default.

source
forward_deg(a, f, lon, lat, azi, angle) -> lon′, lat′, baz, dist, angle

Compute the final point assuming an ellipsoid with semimajor radius a m and flattening f.

Note that precomputing the ellipsoid with Geodesic and then reusing this if multiple forward_deg calculations are needed will be more efficient.

source
forward_deg(line::GeodesicLine, angle) -> lon, lat, baz, dist

Compute the final point when travelling along a pre-computed great circle line for an angular distance of angle °. dist is the distance in m.

source
GeographicLib.inverseFunction.
inverse([ellipsoid::Geodesic=WGS84,] lon1, lat1, lon2, lat2) -> azi, baz, dist, angle

Compute for forward azimuth azi°, backazimuth baz°, surface distance dist m and angular distance angle° when travelling from (lon1, lat1)° to a second point (lon2, lat2)°.

If ellipsoid is not supplied, then WGS84 is used by default.

source
inverse(a, f, lon1, lat1, lon2, lat2) -> azi, baz, dist, angle

Compute the final point assuming an ellipsoid with semimajor radius a m and flattening f.

Note that precomputing the ellipsoid with Geodesic(a, f) and then reusing this if multiple inverse calculations are needed will be more efficient.

source
waypoints(line::GeodesicLine; n, dist, angle) -> points

Return a set of points along a great circle line (which must have been specified with a distance or as between two points). There are three options:

  • Specify n, the number of points (including the endpoints)
  • Specift dist, the distance between each point in m
  • Specify angle, the angular distance between each point in °.

In all cases, the start and end points are always included. When giving either dist or angle, the penultimate point may not be respectively dist m or angle° away from the final point.

The output is a vector of named tuples as returned by forward or forward_deg.

source

Polygons

add_point!(polygon, lon, lat) -> polygon

Add a point to a geodesic polygon in order to later compute its perimeter and area with properties.

source
add_edge!(polygon, azi, dist) -> polygon

Add a point to a polygon by specifying the azimuth azi (°) and distance dist (m) from the previous point, in order to later compute its perimeter and area with properties.

source
properties(polygon::Polygon) -> npoints, perimeter, area

Return the number of points npoints, perimeter (m) and area (m²) of the geodesic polygon.

source

Included ellipsoids

GeographicLib.WGS84Constant.

Ellipsoid of the WGS84 system, with a semimajor radius of 6.378137e6 m and flattening 0.0033528106647474805.

source