Take two SpatialLines objects and update the geometry of the former with that of the latter, retaining the data of the former.

update_line_geometry(l, nl)

Arguments

l

A SpatialLines object, whose geometry is to be modified

nl

A SpatialLines object of the same length as l to provide the new geometry

See also

Examples

data(flowlines) l <- flowlines[2:5, ] nl <- routes_fast nrow(l)
#> [1] 4
nrow(nl)
#> [1] 49
l <- l[!is_linepoint(l), ] names(l)
#> [1] "Area.of.residence" #> [2] "Area.of.workplace" #> [3] "All" #> [4] "Work.mainly.at.or.from.home" #> [5] "Underground..metro..light.rail..tram" #> [6] "Train" #> [7] "Bus..minibus.or.coach" #> [8] "Taxi" #> [9] "Motorcycle..scooter.or.moped" #> [10] "Driving.a.car.or.van" #> [11] "Passenger.in.a.car.or.van" #> [12] "Bicycle" #> [13] "On.foot" #> [14] "Other.method.of.travel.to.work" #> [15] "id"
names(routes_fast)
#> [1] "plan" "start" "finish" "length" "time" #> [6] "waypoint" "cum_hill" "change_elev" "dif_max_min" "up_tot" #> [11] "down_tot" "av_incline" "co2_saving" "calories" "busyness" #> [16] "ID"
l_newgeom <- update_line_geometry(l, nl) plot(l, lwd = l$All / mean(l$All))
plot(l_newgeom, lwd = l$All / mean(l$All))
names(l_newgeom)
#> [1] "Area.of.residence" #> [2] "Area.of.workplace" #> [3] "All" #> [4] "Work.mainly.at.or.from.home" #> [5] "Underground..metro..light.rail..tram" #> [6] "Train" #> [7] "Bus..minibus.or.coach" #> [8] "Taxi" #> [9] "Motorcycle..scooter.or.moped" #> [10] "Driving.a.car.or.van" #> [11] "Passenger.in.a.car.or.van" #> [12] "Bicycle" #> [13] "On.foot" #> [14] "Other.method.of.travel.to.work" #> [15] "id"