
Last chance! 50% off unlimited learning
Sale ends in
cents
).
The data is from the UK and is available as open data:
http://wicid.ukdataservice.ac.uk/.
data(flow)
Although these variable names are unique to UK data, the data
structure is generalisable and typical of flow data from any source.
The key variables are the origin and destination ids, which link to
the cents
georeferenced spatial objects.
## Not run:
# # This is how the dataset was constructed - see
# # https://github.com/npct/pct - if download to ~/repos
# flow <- readRDS("~/repos/pct/pct-data/national/flow.Rds")
# data(cents)
# o <- flow$Area.of.residence %in% cents$geo_code[-1]
# d <- flow$Area.of.workplace %in% cents$geo_code[-1]
# flow <- flow[o & d, ] # subset flows with o and d in study area
# library(devtools)
# flow$id <- paste(flow$Area.of.residence, flow$Area.of.workplace)
# use_data(flow, overwrite = TRUE)
#
# # Convert flows to SpatialLinesDataFrame
# flowlines <- od2line(flow = flow, zones = cents)
# # use_data(flowlines, overwrite = TRUE)
#
# # Convert flows to routes
# routes_fast <- line2route(l = flowlines, plan = "fastest")
# routes_slow <- line2route(l = flowlines, plan = "quietest")
#
# use_data(routes_fast)
# use_data(routes_slow)
# ## End(Not run)
Run the code above in your browser using DataLab