earth.dist: Calculating Geographic Distances

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Create a distance matrix (lower triangle) between a list of points

Usage

1
earth.dist(lats, dist = TRUE)

Arguments

lats

a table with a longitude and latitude column respectively as the first two columns

dist

A logical argument whether to create a distance matrix (lower triangle) or full matrix

Details

This function will calculate the pairwise distances between all points given and return either a distance or full matrix as specified. All coordinates must be in decimal degrees.

Value

Returns a matrix of distances in kilometers between a list of longitudes and latitudes.

Note

Large datasets may take some time to process, as the number of distances to calculate is factorial in nature.

Author(s)

Matthew Vavrek, with suggestions from Anton Korobeynikovs

See Also

deg.dist

Examples

1
2

Example output

Loading required package: sp
Loading required package: maps
Loading required package: shapefiles
Loading required package: foreign

Attaching package: 'shapefiles'

The following objects are masked from 'package:foreign':

    read.dbf, write.dbf

           1         2         3         4         5         6         7
2   893.4992                                                            
3   776.3101  867.2648                                                  
4  1101.1145  777.6345 1517.9088                                        
5  1477.4800  860.9163  893.8599 1620.1478                              
6   444.9052  452.7447  734.2119  804.9868 1157.2559                    
7   456.5888  694.5158 1039.0445  648.1190 1484.7696  341.3085          
8  1559.4614  691.1420 1499.0430  917.0698 1061.3502 1115.6862 1250.8021
9  1435.2985 1205.4321  665.9257 1971.6276  624.2802 1291.3577 1628.1184
10 1481.0119 1625.9999  800.5519 2317.0658 1255.8598 1532.7376 1821.8866
11 1152.0352 1384.0059  521.5133 2031.2737 1188.1836 1233.7579 1507.0925
12  870.4960  716.6949 1351.4342  238.2070 1577.5883  619.6457  414.4991
           8         9        10        11
2                                         
3                                         
4                                         
5                                         
6                                         
7                                         
8                                         
9  1625.1876                              
10 2173.8323  645.4596                    
11 1986.6517  667.3578  331.0349          
12 1036.5724 1859.0932 2151.4155 1853.1005

fossil documentation built on March 23, 2020, 5:06 p.m.