Aliases: od_jitter
Keywords:
### ** Examples # Basic example od = od_data_df z = od_data_zones_min dlr = od_jitter(od, z) # desire_lines_random
desire_lines = od_to_sf(od, z)
plot(z$geometry) plot(dlr["all"], add = TRUE, lwd = 3) dlr$all
[1] 966 1145 1791 1035 453 286 753
desire_lines$all
[1] 966 1145 1791 1035 453 286 753
plot(desire_lines["all"], add = TRUE, lwd = 5)
# Example showing use of subpoints subpoints_o = sf::st_sample(z, 200) subpoints_d = sf::st_sample(z, 100) dlr_d = od_jitter(od, z, subpoints_o = subpoints_o, subpoints_d = subpoints_d)
plot(z$geometry) plot(dlr_d$geometry, add = TRUE) plot(subpoints_o, add = TRUE) plot(subpoints_d, col = "red", add = TRUE) plot(desire_lines, add = TRUE, lwd = 5)
Warning in plot.sf(desire_lines, add = TRUE, lwd = 5): ignoring all but the first attribute
# mapview::mapview(desire_lines) + dlr + z # interactive map sp = sf::st_sample(z, 100) dlr2 = od_jitter(desire_lines, z, subpoints_o = sp, subpoints_d = sp) plot(z$geometry) plot(sp, add = TRUE) plot(dlr2, add = TRUE, lwd = 3)
Warning in plot.sf(dlr2, add = TRUE, lwd = 3): ignoring all but the first attribute
plot(desire_lines, add = TRUE, lwd = 5)
Warning in plot.sf(desire_lines, add = TRUE, lwd = 5): ignoring all but the first attribute
# Example showing jittering with origin and destination zones od = od_data_df2 z = sf::st_buffer(od_data_centroids2, dist = 1000) zd = sf::st_buffer(od_data_destinations, dist = 300) zd = zd[zd[[1]] %in% od[[2]], ] desire_lines = od_to_sf(od, od_data_centroids2, zd = od_data_destinations)
dlr = od_jitter(od, z, zd = zd)
plot(z$geometry) plot(od_data_centroids2$geometry, add = TRUE) plot(od_data_destinations$geometry, add = TRUE) plot(zd$geometry, add = TRUE) plot(dlr, add = TRUE, lwd = 3)
Warning in plot.sf(dlr, add = TRUE, lwd = 3): ignoring all but the first attribute
plot(desire_lines, add = TRUE, lwd = 5)
Warning in plot.sf(desire_lines, add = TRUE, lwd = 5): ignoring all but the first attribute
# Larger example with only subset of matching zones # od = od_data_df_medium # od_sf = od_to_sf(od, od_data_zones) # dlr3 = od_jitter(od_sf, od_data_zones) # plot(od_sf[od$all > 200, 1]) # plot(dlr3[od$all > 200, 1]) # mapview::mapview(od_sf$geometry[od$all > 200])