Julia interface functions
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.
GeographicLib.Geodesics.Geodesic
— Type.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
.
GeodesicLine
The GeodesicLine
type includes an ellipsoid and defines a particular great circle on that ellipsoid.
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
).
GeographicLib.GeodesicLines.GeodesicLine
— Method.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:
- Set a start point, azimuth, and optionally distance. This requires the keyword arguments
azi1
(all °) and optionally eitherangle
(angular distance, °) or distancedist
(m). - Set a start point and end point. This requires the keyword arguments
lon2
andlat2
(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
.
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
.
GeographicLib.Polygons.Polygon
— Type.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.
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
.
Functions
Geodesic
s and GeodesicLine
s
GeographicLib.forward
— Function.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.
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.
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 °.
GeographicLib.forward_deg
— Function.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.
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.
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.
GeographicLib.inverse
— Function.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.
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.
GeographicLib.waypoints
— Function.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
.
Polygon
s
GeographicLib.add_point!
— Function.add_point!(polygon, lon, lat) -> polygon
Add a point to a geodesic polygon in order to later compute its perimeter and area with properties
.
GeographicLib.add_edge!
— Function.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
.
GeographicLib.properties
— Function.properties(polygon::Polygon) -> npoints, perimeter, area
Return the number of points npoints
, perimeter
(m) and area
(m²) of the geodesic polygon
.
Included ellipsoids
GeographicLib.WGS84
— Constant.Ellipsoid of the WGS84 system, with a semimajor radius of 6.378137e6 m and flattening 0.0033528106647474805.