polyUtils: Great circle distance from longlat coordinates

gcDistR Documentation

Great circle distance from longlat coordinates

Description

given the coordinates in the longitude and latitude it computes the distance between these points. The default distance computed is in kilometers.

Usage

gcDist(x1, y1, x2, y2, R = 6371)

Arguments

x1

longitude of the first location set

y1

latitude of the second location set

x2

longitude of the first location set

y2

latitude of the second location set

R

the radius. Default is 6371 giving the the resulting distance in kilometers for the chordal distance around the Earth.

Examples


## Consider some locations
locs <- rbind(
  Paris=c(2.3295489, 48.8588377),
  Berlin=c(13.4072169, 52.5067614),
  Curitiba=c(-49.2582225, -25.4420471),
  Tokyo=c(139.6708224, 35.6681625))
locs

apply(locs, 1, function(xy)
  gcDist(xy[1], xy[2], locs[,1], locs[,2]))


eliaskrainski/emisc documentation built on Nov. 18, 2024, 11:02 a.m.