nbdists: Spatial link distance measures

Description Usage Arguments Value Author(s) See Also Examples

View source: R/nbdists.R

Description

Given a list of spatial neighbour links (a neighbours list of object type nb), the function returns the Euclidean distances along the links in a list of the same form as the neighbours list. If longlat = TRUE, Great Circle distances are used.

Usage

1
nbdists(nb, coords, longlat = NULL)

Arguments

nb

an object of class nb

coords

matrix of point coordinates or a SpatialPoints object

longlat

TRUE if point coordinates are longitude-latitude decimal degrees, in which case distances are measured in kilometers; if coords is a SpatialPoints object, the value is taken from the object itself

Value

A list with class nbdist

Author(s)

Roger Bivand Roger.Bivand@nhh.no

See Also

summary.nb, nb2listw

Examples

1
2
3
4
5
example(columbus)
coords <- coordinates(columbus)
dlist <- nbdists(col.gal.nb, coords)
dlist <- lapply(dlist, function(x) 1/x)
stem(unlist(dlist))

Example output

Loading required package: sp
Loading required package: Matrix

colmbs> require(maptools)
Loading required package: maptools
Checking rgeos availability: TRUE

colmbs> columbus <- readShapePoly(system.file("etc/shapes/columbus.shp",
colmbs+  package="spdep")[1])

colmbs> col.gal.nb <- read.gal(system.file("etc/weights/columbus.gal",
colmbs+  package="spdep")[1])
Warning message:
use rgdal::readOGR or sf::st_read 

  The decimal point is at the |

  1 | 1111112222223333334444444444
  1 | 555555556666667777777777888888888899999999999999999999
  2 | 00000000111111111111111122222222222222333333333333334444
  2 | 55555555556666666666666677777777888888999999
  3 | 0000111111222233334444
  3 | 77779999
  4 | 223344
  4 | 77
  5 | 001144
  5 | 
  6 | 
  6 | 99
  7 | 
  7 | 88

spdep documentation built on Aug. 19, 2017, 3:01 a.m.