Skip to content

route_dodgr() doesn't pass attributes back #571

@meptrsn

Description

@meptrsn

One task I've been working on at work (I work for a transportation department in a major US city) on has been estimating traffic routing within a compact neighborhood area. We have O-D counts at a cordon around the edge, and there's a compact network of streets within the cordon. We are looking to estimate the volume shifts on different links expected from a few changes to traffic circulation within the cordon, changing street directionality and stuff like that.

To do this, I've written an R script that takes in a large amount of OD data and locations of Os and Ds, with volumes for each OD pair. Ideally, I'd like to route these over the existing network (to compare to counts we have and feel some level of confidence in the routing algorithm being close enough to human behavior) and then route those OD pairs over an edited network within the cordon (deleted links, altered link direction, etc).

Here's an abbreviated example:

library(stplanr)
library(sf)
library(dplyr)

AV_roads_filter <- read_sf("AV_roads_filter_sh.shp") %>% rename(highway = type)

AV_dl_wkdy_AM <- read_sf("AV_dl_wkdy_AM.shp")

AV_am_rt <- route_dodgr(l = AV_dl_wkdy_AM, net = AV_roads_filter)

(the AV stands for Allston Village, the neighborhood we are studying, not autonomous vehicles).

When I run this (apologies, the base files aren't accepted by github) I get the following output:

Simple feature collection with 506 features and 6 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: -71.13917 ymin: 42.34926 xmax: -71.12364 ymax: 42.35687
Geodetic CRS:  WGS 84
First 10 features:
         from    from_x   from_y          to      to_x     to_y                       geometry
1  5458202330 -71.13466 42.35294  6602962456 -71.13466 42.35294 LINESTRING (-71.13466 42.35...
2  5458202330 -71.13466 42.35294    61341205 -71.13466 42.35294 LINESTRING (-71.13466 42.35...
3  5458202330 -71.13466 42.35294  9834834499 -71.13466 42.35294 LINESTRING (-71.13466 42.35...
4  5458202330 -71.13466 42.35294  9879661460 -71.13466 42.35294 LINESTRING (-71.13466 42.35...
5  5458202330 -71.13466 42.35294 11980004029 -71.13466 42.35294 LINESTRING (-71.13466 42.35...

The resulting route table doesn't have any of the volume attributes that accompanied the OD pairs. However, this feature, is accommodated in the route() function, with the exception that the the route() function doesn't allow for custom road networks to be used. Am I missing a functionality in either route_dodgr() or route() that I could be using more fruitfully?

For reference, here's the heads of both AV_dl_wkdy_AM and AV_roads_filter:

> AV_dl_wkdy_AM
Simple feature collection with 383 features and 5 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: -71.13934 ymin: 42.34966 xmax: -71.12364 ymax: 42.35635
Geodetic CRS:  WGS 84
# A tibble: 383 × 6
   Org_Z_N                        Dst_Z_N                              Day_Typ           Day_Prt               A_D_O_D                         geometry
   <chr>                          <chr>                                <chr>             <chr>                   <int>                 <LINESTRING [°]>
 1 Allston Street / 102521640 / 7 Ashford Street / 435483296 / 1       1: Weekday (M-Th) 2: Peak AM (6am-10am)       1 (-71.13476 42.35281, -71.12903 …
 2 Allston Street / 102521640 / 7 Cambridge Street / 1088539388 / 1    1: Weekday (M-Th) 2: Peak AM (6am-10am)     476 (-71.13476 42.35281, -71.13056 …
 3 Allston Street / 102521640 / 7 Cambridge Street / 426491734 / 1     1: Weekday (M-Th) 2: Peak AM (6am-10am)      12 (-71.13476 42.35281, -71.13778 …
 4 Allston Street / 102521640 / 7 Chester Street / 8648202 / 1         1: Weekday (M-Th) 2: Peak AM (6am-10am)       1 (-71.13476 42.35281, -71.1282 4…
 5 Allston Street / 102521640 / 7 Commonwealth Avenue / 1055101268 / 2 1: Weekday (M-Th) 2: Peak AM (6am-10am)      38 (-71.13476 42.35281, -71.12374 …
 6 Allston Street / 102521640 / 7 Commonwealth Avenue / 570156797 / 1  1: Weekday (M-Th) 2: Peak AM (6am-10am)       1 (-71.13476 42.35281, -71.13201 …
 7 Allston Street / 102521640 / 7 Commonwealth Avenue / 570156799 / 1  1: Weekday (M-Th) 2: Peak AM (6am-10am)       4 (-71.13476 42.35281, -71.13208 …
 8 Allston Street / 102521640 / 7 Denby Road / 8652501 / 1             1: Weekday (M-Th) 2: Peak AM (6am-10am)       1 (-71.13476 42.35281, -71.13486 …
 9 Allston Street / 102521640 / 7 Emery Road / 8646217 / 1             1: Weekday (M-Th) 2: Peak AM (6am-10am)       0 (-71.13476 42.35281, -71.13598 …
10 Allston Street / 102521640 / 7 Everett Street / 1086100238 / 1      1: Weekday (M-Th) 2: Peak AM (6am-10am)     270 (-71.13476 42.35281, -71.13895 …
Simple feature collection with 403 features and 7 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: -71.15095 ymin: 42.34215 xmax: -71.12112 ymax: 42.3594
Geodetic CRS:  WGS 84
# A tibble: 403 × 8
    osm_id name                           ref   highway     oneway bridge maxspeed                                                             geometry
     <dbl> <chr>                          <chr> <chr>        <int>  <int>    <int>                                                     <LINESTRING [°]>
 1 8636209 Corey Road                     NA    tertiary         0      0       25 (-71.14044 42.34241, -71.1404 42.34244, -71.14035 42.34247, -71.140…
 2 8636423 Lieutenant Pamela Donovan Road NA    residential      0      0       20 (-71.14555 42.34705, -71.14533 42.3472, -71.14523 42.34727, -71.145…
 3 8636424 Lieutenant Pamela Donovan Road NA    residential      0      0       20 (-71.14624 42.34611, -71.14617 42.34617, -71.14609 42.34625, -71.14…
 4 8636450 Commonwealth Court             NA    residential      0      0       NA (-71.14054 42.34631, -71.14048 42.34629, -71.13929 42.3459, -71.139…
 5 8636516 Harvard Avenue                 NA    primary          0      0       NA (-71.12974 42.34885, -71.12978 42.3489, -71.12989 42.34905, -71.129…
 6 8636554 Ashford Court                  NA    residential      0      0       NA (-71.12616 42.35431, -71.12614 42.35431, -71.12613 42.35431, -71.12…
 7 8636556 Ashford Court                  NA    residential      0      0       NA           (-71.12613 42.35431, -71.1261 42.35445, -71.12609 42.3545)
 8 8636827 Lincoln Street                 NA    tertiary         0      0       NA (-71.14174 42.3581, -71.14274 42.35823, -71.14351 42.35832, -71.143…
 9 8637529 Thor Terrace                   NA    residential      0      0       NA (-71.13358 42.3542, -71.13361 42.35426, -71.13376 42.35456, -71.133…
10 8637562 Arthur Street                  NA    residential      0      0       NA (-71.14201 42.35558, -71.14194 42.35569, -71.1418 42.3559, -71.1417…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions