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

Arguments

x

SpatialLinesNetwork to use

varname

The name of the variable to set/use.

value

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.

Details

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.

Examples

# with sp objects data(routes_fast) rnet <- overline(routes_fast, attrib = "length")
#> Warning: Too few points in geometry component at or near point -1.51673372 53.828874089999999
#> Warning: Too few points in geometry component at or near point -1.5356168100000001 53.828472859999998
#> Warning: Too few points in geometry component at or near point -1.5508065 53.824420150000002
#> Warning: Too few points in geometry component at or near point -1.5307123300000001 53.817556189999998
#> Warning: Too few points in geometry component at or near point -1.5193175299999999 53.815796030000001
#> Warning: Too few points in geometry component at or near point -1.51186139 53.811610979999998
#> Warning: Too few points in geometry component at or near point -1.5242047000000001 53.804098449999998
#> Warning: Too few points in geometry component at or near point -1.51673372 53.828874089999999
#> Warning: Too few points in geometry component at or near point -1.5356168100000001 53.828472859999998
#> Warning: Too few points in geometry component at or near point -1.5508065 53.824420150000002
#> Warning: Too few points in geometry component at or near point -1.5307123300000001 53.817556189999998
#> Warning: Too few points in geometry component at or near point -1.5193175299999999 53.815796030000001
#> Warning: Too few points in geometry component at or near point -1.51186139 53.811610979999998
#> Warning: Too few points in geometry component at or near point -1.5242047000000001 53.804098449999998
#> sl is invalid
#> sl is invalid
#> Warning: Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
sln <- SpatialLinesNetwork(rnet)
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
#> Warning: CRS object has comment, which is lost in output
weightfield(sln) <- "length" weightfield(sln, "randomnum") <- sample(1:10, size = nrow(sln@sl), replace = TRUE) data(routes_fast_sf) rnet <- overline(routes_fast_sf, attrib = "length") sln <- SpatialLinesNetwork(rnet) weightfield(sln) <- "length" sln@sl$randomnum <- sample(1:10, size = nrow(sln@sl), replace = TRUE) weightfield(sln) <- "randomnum" # todo: show the difference that it makes