Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

geopath

Geopath — shortest trajectory line between two geographic locations


Description

Derives a SpatialLines class object showing the shortest path between the two geographic locations and based on the Haversine Formula for Great Circle distance.

Usage

geopath(lon1, lon2, lat1, lat2, ID, n.points, print.geo = FALSE)

Arguments

lon1

longitude coordinate of the first point

lon2

longitude coordinate of the second point

lat1

latitude coordinate of the first point

lat2

latitude coordinate of the second point

ID

(optional) point ID character

n.points

number of intermediate points

print.geo

prints the distance and bearing

Details

Number of points between the start and end point is derived using a simple formula:

round(sqrt(distc)/sqrt(2), 0)

where distc is the Great Circle Distance.

Value

Bearing is expressed in degrees from north. Distance is expressed in kilometers (Great Circle Distance).

Author(s)

Tomislav Hengl

References

See Also

Examples

library(fossil)
ams.ny <- geopath(lon1=4.892222, lon2=-74.005973, 
          lat1=52.373056, lat2=40.714353, print.geo=TRUE)
kml.file = paste0(tempdir(), "/ams.ny.kml")
# write to a file:
kml(ams.ny, file.name=kml.file)

plotKML

Visualization of Spatial and Spatio-Temporal Objects in Google Earth

v0.8-1
GPL
Authors
Tomislav Hengl [cre, aut], Andrea Gilardi [ctb], Pierre Roudier [ctb], Dylan Beaudette [ctb], Edzer Pebesma [ctb], Michael Blaschek [ctb]
Initial release
2021-04-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.