Description Usage Arguments Details Value Author(s) References See Also Examples
Calculation of an euclidean distance matrix between points with stated coordinates (lat, lon)
1 2 |
startpoints |
A data frame containing the start points |
sp_id |
Column containing the IDs of the startpoints in the data frame |
lat_start |
Column containing the latitudes of the start points in the data frame |
lon_start |
Column containing the longitudes of the start points in the data frame |
endpoints |
A data frame containing the end points |
ep_id |
Column containing the IDs of the endpoints in the data frame |
lat_end |
Column containing the latitudes of the end points in the data frame |
lon_end |
Column containing the longitudes of the end points in the data frame |
unit |
Unit of the resulting distance: |
The function calculates an euclidean distance matrix between points with stated coordinates (lat and lon). While m start points and n end points are given, the output is a linear m * n distance matrix.
The function returns a data.frame
containing 4 columns: The start point IDs (from
), the end point IDs (to
), the combination of both (from_to
) and the calculated distance (distance
).
Thomas Wieland
de Lange, N. (2013): “Geoinformatik in Theorie und Praxis”. 3rd edition. Berlin : Springer Spektrum.
Krider, R. E./Putler, R. S. (2013): “Which Birds of a Feather Flock Together? Clustering and Avoidance Patterns of Similar Retail Outlets”. In: Geographical Analysis, 45, 2, p. 123-149
1 2 3 4 5 6 7 8 9 | citynames <- c("Goettingen", "Karlsruhe", "Freiburg")
lat <- c(51.556307, 49.009603, 47.9874)
lon <- c(9.947375, 8.417004, 7.8945)
citynames <- c("Goettingen", "Karlsruhe", "Freiburg")
cities <- data.frame(citynames, lat, lon)
dist.mat (cities, "citynames", "lat", "lon", cities, "citynames", "lat", "lon")
# Euclidean distance matrix (3 x 3 cities = 9 distances)
dist.buf (cities, "citynames", "lat", "lon", cities, "citynames", "lat", "lon", bufdist = 300000)
# Cities within 300 km
|
from to from_to distance
1 Goettingen Goettingen Goettingen-Goettingen 0.0000
2 Karlsruhe Goettingen Karlsruhe-Goettingen 303.6554
3 Freiburg Goettingen Freiburg-Goettingen 423.7633
4 Goettingen Karlsruhe Goettingen-Karlsruhe 303.6554
5 Karlsruhe Karlsruhe Karlsruhe-Karlsruhe 0.0000
6 Freiburg Karlsruhe Freiburg-Karlsruhe 120.1379
7 Goettingen Freiburg Goettingen-Freiburg 423.7633
8 Karlsruhe Freiburg Karlsruhe-Freiburg 120.1379
9 Freiburg Freiburg Freiburg-Freiburg 0.0000
$count_table
from count_citynames
1 Freiburg 1
2 Goettingen 0
3 Karlsruhe 1
$distmat
from to from_to distance count
2 Karlsruhe Goettingen Karlsruhe-Goettingen 303655.4 0
3 Freiburg Goettingen Freiburg-Goettingen 423763.3 0
4 Goettingen Karlsruhe Goettingen-Karlsruhe 303655.4 0
6 Freiburg Karlsruhe Freiburg-Karlsruhe 120137.9 1
7 Goettingen Freiburg Goettingen-Freiburg 423763.3 0
8 Karlsruhe Freiburg Karlsruhe-Freiburg 120137.9 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.