# pointDistance

0th

Percentile

##### Distance between points

Calculate the geographic distance between two (sets of) points on a sphere (longlat=TRUE) or on a plane (longlat=FALSE).

Keywords
spatial
##### Usage
pointDistance(p1, p2, longlat, ...)
##### Arguments
p1
x and y coordinate of first (set of) point(s), either as c(x, y), matrix(ncol=2), or SpatialPoints*.
p2
x and y coordinate of second (set of) second point(s) (like for p1). If this argument is missing, a distance matrix is computed for p1
longlat
Logical. If TRUE, coordinates should be in degrees; else they should represent planar ('Euclidean') space (e.g. units of meters)
...
Additional arguments. Can be used to set the radius, r, of the world (modeled as a sphere), when longlat=TRUE Default is r=6378137
##### Value

• A single value, or a vector, or matrix of values giving the distance in meters (longlat=TRUE) or map-units (for instance, meters in the case of UTM) If p2 is missing, a distance matrix is returned

distanceFromPoints, distance, gridDistance, spDistsN1. The geosphere package has many additional distance functions and other functions that operate on spherical coordinates

##### Aliases
• pointDistance
##### Examples
a <- cbind(c(1,5,55,31),c(3,7,20,22))
b <- cbind(c(4,2,8,65),c(50,-90,20,32))

pointDistance(c(0, 0), c(1, 1), longlat=FALSE)
pointDistance(c(0, 0), c(1, 1), longlat=TRUE)
pointDistance(c(0, 0), a, longlat=TRUE)
pointDistance(a, b, longlat=TRUE)

#Make a distance matrix
dst <- pointDistance(a, longlat=TRUE)
# coerce to dist object
dst <- as.dist(dst)
Documentation reproduced from package raster, version 2.1-41, License: GPL (>= 3)

### Community examples

Looks like there are no examples yet.