dist_geographic: Geographical distances

View source: R/geographic.R

dist_geographicR Documentation

Geographical distances

Description

This function calculate some geographical distances considering a list of places specifying their latitud and longitud. The function currently works for degree decimal or radians formats.

Usage

dist_geographic(
  latitude,
  longitud,
  method = c("spherical", "harvesine", "manhattan", "minkowski"),
  places = NULL,
  dd_to_radians = FALSE,
  p = NULL
)

Arguments

latitude

A vector with latitude

longitud

A vector with longitud

method

Whether to use the Spherical Law of Cosines spherical (default), Haversine formula harvesine, Manhattan Distance manhattan or Minkoowski distance minkowski

places

A vector with the names of the places

dd_to_radians

Whether to transform degree decimal format to radians

p

Parameter p for the estimation of Minkowski distance (default = 2, which is equivalent to an Euclidian Distance)

Value

This function return a distance matrix.

Source

Adapted from Mario Pineda-Krch (Great-circle distance calculations in R)

Examples


set.seed(1234)
x <- cbind(latitud = rnorm(5, -90), longitud = rnorm(5, 45))
dist_geographic(x[, 1], x[, 2], method = "harvesine")

anespinosa/netmem documentation built on April 5, 2025, 5:02 p.m.