-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathrnet_merge.Rd
79 lines (72 loc) · 2.63 KB
/
rnet_merge.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rnet_join.R
\name{rnet_merge}
\alias{rnet_merge}
\title{Merge route networks, keeping attributes with aggregating functions}
\usage{
rnet_merge(
rnet_x,
rnet_y,
dist = 5,
funs = NULL,
sum_flows = TRUE,
crs = geo_select_aeq(rnet_x),
...
)
}
\arguments{
\item{rnet_x}{Target route network, the output will have the same geometries
as features in this object.}
\item{rnet_y}{Source route network. Columns from this route network object will
be copied across to the new network.}
\item{dist}{The buffer width around rnet_y in meters. 1 m by default.}
\item{funs}{A named list of functions to apply to named columns, e.g.:
\code{list(flow = sum, length = mean)}. The default is to sum all numeric
columns.}
\item{sum_flows}{Should flows be summed? \code{TRUE} by default.}
\item{crs}{The CRS to use for the buffer operation. See \code{?geo_projected} for details.}
\item{...}{Additional arguments passed to \code{rnet_join}.}
}
\value{
An sf object with the same geometry as \code{rnet_x}
}
\description{
This is a small wrapper around \code{rnet_join()}.
In most cases we recommend using \code{\link[=rnet_join]{rnet_join()}} directly,
as it gives more control over the results
}
\examples{
# The source object:
rnet_y <- route_network_small["flow"]
# The target object
rnet_x <- rnet_subset(osm_net_example[1], rnet_y)
plot(rnet_x$geometry, lwd = 5)
plot(rnet_y$geometry, add = TRUE, col = "red", lwd = 2)
rnet_y$quietness <- rnorm(nrow(rnet_y))
funs <- list(flow = sum, quietness = mean)
rnet_merged <- rnet_merge(rnet_x[1], rnet_y[c("flow", "quietness")],
dist = 9, segment_length = 20, funs = funs
)
plot(rnet_y$geometry, lwd = 5, col = "lightgrey")
plot(rnet_merged["flow"], add = TRUE, lwd = 2)
# # With a different CRS
rnet_xp <- sf::st_transform(rnet_x, "EPSG:27700")
rnet_yp <- sf::st_transform(rnet_y, "EPSG:27700")
rnet_merged <- rnet_merge(rnet_xp[1], rnet_yp[c("flow", "quietness")],
dist = 9, segment_length = 20, funs = funs
)
plot(rnet_merged["flow"])
# rnet_merged2 = rnet_merge(rnet_x[1], rnet_y[c("flow", "quietness")],
# dist = 9, segment_length = 20, funs = funs,
# crs = "EPSG:27700")
# waldo::compare(rnet_merged, rnet_merged2)
# plot(rnet_merged$flow, rnet_merged2$flow)
# # Larger example
# system("gh release list")
# system("gh release upload v1.0.2 rnet_*")
# List the files released in v1.0.2:
# system("gh release download v1.0.2")
# rnet_x = sf::read_sf("rnet_x_ed.geojson")
# rnet_y = sf::read_sf("rnet_y_ed.geojson")
# rnet_merged = rnet_merge(rnet_x, rnet_y, dist = 9, segment_length = 20, funs = funs)
}