Haversines are not Slow

The haversine is a function used to calculate the distance between a pair of latitude and longitude points while accounting for the assumption that the points are on a spherical globe. This package provides a fast, dataframe compatible, haversine function. For the first publication on the haversine calculation see Joseph de Mendoza y RĂ­os (1795) < https://books.google.cat/books?id=030t0OqlX2AC> (In Spanish).


hans

The goal of hans is to make a fast dataframe compatible haversine function.

Installation

You can install the released version of hans from CRAN with:

install.packages("hans")

Example

This is a basic example which shows you how to solve a common problem:

library(tibble)
library(dplyr)
library(magrittr)

set.seed(42)
lon1 <- runif(-160, -60, n = 1e6)
lat1 <- runif(40, 60, n = 1e6)
lon2 <- runif(-160, -60, n = 1e6)
lat2 <- runif(40, 60, n = 1e6)

df <- tibble::tibble(lat1, lon1, lat2, lon2) %>% 
  mutate(hav = haversine(lat1, lon1, lat2, lon2))

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("hans")

0.1 by Alex Hallam, 7 years ago


Browse source code at https://github.com/cran/hans


Authors: Alex Hallam [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp

Suggests testthat

Linking to Rcpp


See at CRAN