Get or set value of weight field in SpatialLinesNetwork
weightfield(x)weightfield(x, varname) <- value
weightfield(x, varname) <- value
# S4 method for SpatialLinesNetwork
weightfield(x)
# S4 method for sfNetwork
weightfield(x)
# S4 method for SpatialLinesNetwork,ANY
weightfield(x) <- value
# S4 method for sfNetwork,ANY
weightfield(x) <- value
# S4 method for SpatialLinesNetwork,character
weightfield(x, varname) <- value
# S4 method for sfNetwork,character
weightfield(x, varname) <- value
SpatialLinesNetwork to use
The name of the variable to set/use.
Either the name of the variable to use as the weight field or
a dataframe or vector containing the weights to use if varname
is
passed to the replacement function. If the dataframe contains multiple
columns, the column with the same name as varname
is used,
otherwise the first column is used.
These functions manipulate the value of weightfield in a SpatialLinesNetwork. When changing the value of weightfield, the weights of the graph network are updated with the values of the corresponding variables.
# NOT RUN {
data(routes_fast)
rnet <- overline(routes_fast, attrib = "length")
sln <- SpatialLinesNetwork(rnet)
weightfield(sln) <- "length"
weightfield(sln, "randomnum") <- sample(1:10, size = nrow(sln@sl), replace = TRUE)
# }
Run the code above in your browser using DataLab