spatial_dist: Distance matrix calculation

Description Usage Arguments Value Examples

View source: R/spatial_dist.R

Description

This function load grid floor and generate the distance matrix

Usage

1
spatial_dist(M, lon.lat = F, mile = F)

Arguments

M

A data.frame contains grid coordinates

lon.lat

If TRUE, the function will use longitude and latitude for calculating geographic distance

mile

If TRUE, the function will yeild distance in mileages. If FALSE, the function will yeild distance in kilometers

Value

A matrix of distance matrix

Examples

1

Example output

Loading required package: fields
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.2-2 (2019-03-07) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

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

    backsolve, forwardsolve

Loading required package: maps
See https://github.com/NCAR/Fields for
 an extensive vignette, other supplements and source code 
Loading required package: reshape2
          1        2        3        4        5        6        7        8
1  0.000000 1.000000 2.000000 3.000000 1.000000 1.414214 2.236068 3.162278
2  1.000000 0.000000 1.000000 2.000000 1.414214 1.000000 1.414214 2.236068
3  2.000000 1.000000 0.000000 1.000000 2.236068 1.414214 1.000000 1.414214
4  3.000000 2.000000 1.000000 0.000000 3.162278 2.236068 1.414214 1.000000
5  1.000000 1.414214 2.236068 3.162278 0.000000 1.000000 2.000000 3.000000
6  1.414214 1.000000 1.414214 2.236068 1.000000 0.000000 1.000000 2.000000
7  2.236068 1.414214 1.000000 1.414214 2.000000 1.000000 0.000000 1.000000
8  3.162278 2.236068 1.414214 1.000000 3.000000 2.000000 1.000000 0.000000
9  2.000000 2.236068 2.828427 3.605551 1.000000 1.414214 2.236068 3.162278
10 2.236068 2.000000 2.236068 2.828427 1.414214 1.000000 1.414214 2.236068
11 2.828427 2.236068 2.000000 2.236068 2.236068 1.414214 1.000000 1.414214
12 3.605551 2.828427 2.236068 2.000000 3.162278 2.236068 1.414214 1.000000
13 3.000000 3.162278 3.605551 4.242641 2.000000 2.236068 2.828427 3.605551
14 3.162278 3.000000 3.162278 3.605551 2.236068 2.000000 2.236068 2.828427
15 3.605551 3.162278 3.000000 3.162278 2.828427 2.236068 2.000000 2.236068
16 4.242641 3.605551 3.162278 3.000000 3.605551 2.828427 2.236068 2.000000
          9       10       11       12       13       14       15       16
1  2.000000 2.236068 2.828427 3.605551 3.000000 3.162278 3.605551 4.242641
2  2.236068 2.000000 2.236068 2.828427 3.162278 3.000000 3.162278 3.605551
3  2.828427 2.236068 2.000000 2.236068 3.605551 3.162278 3.000000 3.162278
4  3.605551 2.828427 2.236068 2.000000 4.242641 3.605551 3.162278 3.000000
5  1.000000 1.414214 2.236068 3.162278 2.000000 2.236068 2.828427 3.605551
6  1.414214 1.000000 1.414214 2.236068 2.236068 2.000000 2.236068 2.828427
7  2.236068 1.414214 1.000000 1.414214 2.828427 2.236068 2.000000 2.236068
8  3.162278 2.236068 1.414214 1.000000 3.605551 2.828427 2.236068 2.000000
9  0.000000 1.000000 2.000000 3.000000 1.000000 1.414214 2.236068 3.162278
10 1.000000 0.000000 1.000000 2.000000 1.414214 1.000000 1.414214 2.236068
11 2.000000 1.000000 0.000000 1.000000 2.236068 1.414214 1.000000 1.414214
12 3.000000 2.000000 1.000000 0.000000 3.162278 2.236068 1.414214 1.000000
13 1.000000 1.414214 2.236068 3.162278 0.000000 1.000000 2.000000 3.000000
14 1.414214 1.000000 1.414214 2.236068 1.000000 0.000000 1.000000 2.000000
15 2.236068 1.414214 1.000000 1.414214 2.000000 1.000000 0.000000 1.000000
16 3.162278 2.236068 1.414214 1.000000 3.000000 2.000000 1.000000 0.000000

SpatialFloor documentation built on May 2, 2019, 1:45 p.m.