The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This vignette is written for users of
trafficCAR who want to work with road networks
beyond the bundled examples.
You will learn how to:
.rda dataset (recommended
for packages).rds dataset (recommended for non-package
projects)trafficCARThe recommended workflows are:
User project: GeoJSON (raw) →
.rds(fast)
R package: GeoJSON (raw) →.rda(CRAN-friendly)
A common source of road data is OpenStreetMap,
accessed via the osmdata package.
Choose a city name or bounding box.
city <- "College Station, Texas, USA"
q <- opq(city) |>
add_osm_feature(key = "highway")
osm <- osmdata_sf(q)Extract road geometries:
roads <- roads[, c("highway", "name", "geometry")]
roads <- sf::st_make_valid(roads)
# Optional: simplify to reduce object size.
# Note: dTolerance is in the units of your coordinate reference system (CRS).
# For best results, consider transforming to a projected CRS with meter units first.
roads <- sf::st_simplify(roads, dTolerance = 10)
unique(sf::st_geometry_type(roads))Only LINESTRING and MULTILINESTRING
geometries are supported by trafficCAR.
.rds (recommended for user
projects)roads_cstat <- sf::st_read("roads_cstat.geojson", quiet = TRUE)
saveRDS(roads_cstat, "roads_cstat.rds")
roads_cstat <- readRDS("roads_cstat.rds").rda (recommended for R
packages)library(usethis)
roads_cstat <- sf::st_read("roads_cstat.geojson", quiet = TRUE)
use_data(roads_cstat, overwrite = TRUE, compress = "xz")library(trafficCAR)
data(roads_small, package = "trafficCAR")
roads_cstat <- roads_small
segs <- roads_to_segments(
roads_cstat,
split_at_intersections = TRUE
)
adj <- build_adjacency(segs)data-raw/
roads_cstat_small.geojson
roads_cstat_small.R
data/
roads_cstat_small.rda
library(sf)
library(trafficCAR)
roads <- sf::st_read("roads_cstat.geojson", quiet = TRUE)
segs <- roads_to_segments(roads)data-raw/ or outside the
package.rds for user projects and
.rda for packagesThese binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.