-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathrnet_group.Rd
95 lines (88 loc) · 3.08 KB
/
rnet_group.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rnet_group.R
\name{rnet_group}
\alias{rnet_group}
\alias{rnet_group.default}
\alias{rnet_group.sfc}
\alias{rnet_group.sf}
\title{Assign segments in a route network to groups}
\usage{
rnet_group(rnet, ...)
\method{rnet_group}{default}(rnet, ...)
\method{rnet_group}{sfc}(
rnet,
cluster_fun = igraph::clusters,
d = NULL,
as.undirected = TRUE,
...
)
\method{rnet_group}{sf}(
rnet,
cluster_fun = igraph::clusters,
d = NULL,
as.undirected = TRUE,
...
)
}
\arguments{
\item{rnet}{An sf, sfc, or sfNetwork object representing a route network.}
\item{...}{Arguments passed to other methods.}
\item{cluster_fun}{The clustering function to use. Various clustering functions
are available in the \code{igraph} package. Default: \code{\link[igraph:clusters]{igraph::clusters()}}.}
\item{d}{Optional distance variable used to classify segments that are
close (within a certain distance specified by \code{d}) to each other but not
necessarily touching}
\item{as.undirected}{Coerce the graph created internally into an undirected
graph with \code{\link[igraph:as.directed]{igraph::as.undirected()}}? TRUE by default, which enables use
of a wider range of clutering functions.}
}
\value{
If the input rnet is an sf/sfc object, it returns an integer vector
reporting the groups of each network element. If the input is an sfNetwork
object, it returns an sfNetwork object with an extra column called
rnet_group representing the groups of each network element. In the latter
case, the connectivity of the spatial object is derived from the sfNetwork
object.
}
\description{
This function assigns linestring features, many of which in an
\code{sf} object can form route networks, into groups.
By default, the function \code{igraph::clusters()} is used to determine
group membership, but any \verb{igraph::cluster*()} function can be used.
See examples and the web page
\href{https://igraph.org/r/doc/communities.html}{igraph.org/r/doc/communities.html}
for more information. From that web page, the following clustering
functions are available:
}
\details{
\verb{cluster_edge_betweenness, cluster_fast_greedy, cluster_label_prop,}
\verb{cluster_leading_eigen, cluster_louvain, cluster_optimal, cluster_spinglass, cluster_walktrap}
}
\note{
These functions rely on the igraph package. If igraph is not installed,
the function will return a message.
}
\examples{
if (requireNamespace("igraph", quietly = TRUE)) {
rnet <- rnet_breakup_vertices(stplanr::osm_net_example)
rnet$group <- rnet_group(rnet)
plot(rnet["group"])
# mapview::mapview(rnet["group"])
rnet$group_25m <- rnet_group(rnet, d = 25)
plot(rnet["group_25m"])
rnet$group_walktrap <- rnet_group(rnet, igraph::cluster_walktrap)
plot(rnet["group_walktrap"])
rnet$group_louvain <- rnet_group(rnet, igraph::cluster_louvain)
plot(rnet["group_louvain"])
rnet$group_fast_greedy <- rnet_group(rnet, igraph::cluster_fast_greedy)
plot(rnet["group_fast_greedy"])
}
}
\seealso{
Other rnet:
\code{\link{gsection}()},
\code{\link{islines}()},
\code{\link{overline}()},
\code{\link{rnet_breakup_vertices}()}
}
\concept{rnet}