net_dist | R Documentation |
This function return distances in meters for between points in a network. It can accept an sf object as origin or destination, or a dataframe with columns for longitud and latitud for origin and destination.
net_dist(
net,
shp_origen,
shp_destino,
pairwise,
crs_projected,
crs_longlat,
join,
id_col,
lon_origen,
lat_origen,
lon_destino,
lat_destino,
simplified,
id_destination = NULL,
matrix_as_table
)
net |
The sf or dodgr_streetnet object representing the network |
shp_origen |
Object with the coordinates of origin (may be a sf or a dataframe object) |
shp_destino |
Object with the coordinates of destination (may be a sf or a dataframe object) |
pairwise |
A logical parameter indicating if the computation must be in a pairwise format. If false, the result is a matrix with distances between each point |
crs_projected |
The EPSG number or proj4 object defined for calculating the nearest neighborhood (if join is true) |
crs_longlat |
The EPSG number or proj4 object defined for computing distances with the dodgr_distances function (not used) |
join |
A logical parameter indicating if the shp_origen and shp_destino must be joined by the nearest neighborhood |
id_col |
String character with the name of the column with the id of the network |
lon_origen |
String character with the name of the column containing the longitud of origin when shp_origen and shp_destino are not sf objects |
lat_origen |
String character with the name of the column containing the latitude of origin when shp_origen and shp_destino are not sf objects |
lon_destino |
String character with the name of the column containing the longitud of destination when shp_origen and shp_destino are not sf objects |
lat_destino |
String character with the name of the column containing the latitude of destination when shp_origen and shp_destino are not sf objects |
simplified |
A logical parameter. If true, the return is not a dataframe |
id_destination |
String character indicating a shp_destino column wanted in the resulting dataframe (tipically an id column) |
matrix_as_table |
A logical parameter. Only used when pairwise is false. The matrix of distances between points is returned as a datframe of three columns (origin, destination, and distance) |
A dataframe, matrix or vector of distances between points along a network
## origin and destination as a dataframe
distancias <- net_dist(vias2, shp_origen = BD_sf3, shp_destino = BD_sf3, pairwise = T, id_col = "edge_id", lon_origen = "lon_or",
lat_origen = "lat_or", lon_destino = "lon_dest", lat_destino = "lat_dest")
## origin and destination is the same, calculating a distance matrix as a sf objects
distancias_tm <- net_dist(tm, estaciones, estaciones, pairwise = F, join = F, matrix_as_table = T)
## origin and destination are sf objects, and the distance is computated to the nearest neighborhood
distancias_tm2 <- net_dist(tm, BD_sf1, estaciones, pairwise = T, join = T, id_destination = "nombre_est")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.