geodesic_direct: Geodesic calculations on the WGS84 ellipsoid

View source: R/geodesic_exact.R

geodesic_directR Documentation

Geodesic calculations on the WGS84 ellipsoid

Description

Solve geodesic problems on the WGS84 ellipsoid using exact algorithms. These functions provide high-precision solutions for:

  • Finding destination points given start, azimuth, and distance (direct problem)

  • Finding distance and azimuths between two points (inverse problem)

  • Generating points along geodesic paths

  • Computing distance matrices

Usage

geodesic_direct(x, azi, s)

geodesic_inverse(x, y)

geodesic_path(x, y, n = 100L)

geodesic_line(x, azi, distances)

geodesic_distance(x, y)

geodesic_distance_matrix(x, y = NULL)

Arguments

x

A two-column matrix or data frame of starting coordinates (longitude, latitude) in decimal degrees.

azi

Numeric vector of azimuths (bearings) in degrees, measured clockwise from north.

s

Numeric vector of distances in meters.

y

A two-column matrix or data frame of ending coordinates (longitude, latitude) in decimal degrees.

n

Integer number of points to generate along the path (including start and end points).

distances

Numeric vector of distances from the starting point in meters.

Details

These functions use the exact geodesic algorithms from GeographicLib, which provide full double-precision accuracy for all points on the WGS84 ellipsoid.

The direct problem finds the destination given a starting point, initial azimuth (bearing), and distance. This is useful for navigation and creating buffers.

The inverse problem finds the shortest path (geodesic) between two points and returns the distance and azimuths at both endpoints.

The azimuth is measured in degrees from north, with positive values clockwise (east) and negative values counter-clockwise (west). The range is -180° to 180° (e.g., 90° = east, -90° = west, 180° or -180° = south).

Value

  • geodesic_direct(): Data frame with columns:

    • lon1, lat1: Starting coordinates

    • azi1: Starting azimuth (degrees)

    • s12: Distance (meters)

    • lon2, lat2: Destination coordinates

    • azi2: Azimuth at destination (degrees)

    • m12: Reduced length (meters)

    • M12, M21: Geodesic scale factors

    • S12: Area under geodesic (square meters)

  • geodesic_inverse(): Data frame with columns:

    • lon1, lat1: Starting coordinates

    • lon2, lat2: Ending coordinates

    • s12: Distance (meters)

    • azi1: Azimuth at start (degrees)

    • azi2: Azimuth at end (degrees)

    • m12: Reduced length (meters)

    • M12, M21: Geodesic scale factors

    • S12: Area under geodesic (square meters)

  • geodesic_path(): Data frame with columns:

    • lon, lat: Coordinates along the path

    • azi: Azimuth at each point (degrees)

    • s: Distance from start (meters)

  • geodesic_line(): Data frame with columns:

    • lon, lat: Coordinates at specified distances

    • azi: Azimuth at each point (degrees)

    • s: Distance from start (meters)

  • geodesic_distance(): Numeric vector of distances in meters (pairwise).

  • geodesic_distance_matrix(): Matrix of distances in meters.

Examples

# Direct problem: Where do you end up starting from London,
# heading east for 1000 km?
geodesic_direct(c(-0.1, 51.5), azi = 90, s = 1000000)

# Inverse problem: Distance from London to New York
geodesic_inverse(c(-0.1, 51.5), c(-74, 40.7))

# Generate a great circle path
path <- geodesic_path(c(-0.1, 51.5), c(-74, 40.7), n = 100)
head(path)

# Multiple distances along a bearing
geodesic_line(c(-0.1, 51.5), azi = 45, distances = c(100, 500, 1000) * 1000)

geographiclib documentation built on March 4, 2026, 9:07 a.m.