Available fields from CycleStreets include:

json2sf_cs(
  results_raw,
  id = 1,
  segments = TRUE,
  route_variables = c("start", "finish", "start_longitude", "start_latitude",
    "finish_longitude", "finish_latitude", "crow_fly_distance", "event", "whence",
    "speed", "itinerary", "plan", "note", "length", "west", "south", "east", "north",
    "leaving", "arriving", "grammesCO2saved", "calories", "edition"),
  cols_to_keep = c("id", "time", "busynance", "quietness", "signalledJunctions",
    "signalledCrossings", "name", "walk", "elevations", "distances", "type", "legNumber",
    "distance", "turn", "startBearing", "color", "provisionName", "start", "finish",
    "start_longitude", "start_latitude", "finish_longitude", "finish_latitude",
    "crow_fly_distance", "event", "whence", "speed", "itinerary", "plan", "note",
    "length", "west", "south", "east", "north", "leaving", "arriving", "grammesCO2saved",
    "calories", "edition", "gradient_segment", 
     "elevation_change",
    "gradient_smooth")
)

Arguments

results_raw

Raw result from CycleStreets.net read-in with readLines or similar

id

id of the result

segments

Return segment level data? TRUE by default.

route_variables

Route level variables

cols_to_keep

Columns to return in output sf object

Details

c("id", "time", "busynance", "quietness", "signalledJunctions",
  "signalledCrossings", "name", "walk", "elevations", "distances",
  "type", "legNumber", "distance", "turn", "startBearing", "color",
  "provisionName", "start", "finish", "start_longitude", "start_latitude",
  "finish_longitude", "finish_latitude", "crow_fly_distance", "event",
  "whence", "speed", "itinerary", "plan", "note", "length", "west",
  "south", "east", "north", "leaving", "arriving", "grammesCO2saved",
  "calories", "edition", "gradient_segment", "elevation_change",
  "gradient_smooth", "geometry")

Examples

from = "Leeds Rail Station"
to = "University of Leeds"
# from_point = tmaptools::geocode_OSM(from)
# to_point = tmaptools::geocode_OSM(to)
from_point = c(-1.54408, 53.79360)
to_point =   c(-1.54802, 53.79618)
# save result from the API call to journey.json
# res_json = journey(from_point, to_point, silent = FALSE, save_raw = TRUE)
# jsonlite::write_json(res_json, "inst/extdata/journey.json")
# f = "inst/extdata/journey.json"
f = system.file(package = "cyclestreets", "extdata/journey.json")
rsf = json2sf_cs(readLines(f), id = 1, segments = TRUE)
names(rsf)
#>  [1] "id"                 "time"               "busynance"         
#>  [4] "quietness"          "signalledJunctions" "signalledCrossings"
#>  [7] "name"               "walk"               "elevations"        
#> [10] "distances"          "type"               "legNumber"         
#> [13] "distance"           "turn"               "startBearing"      
#> [16] "color"              "provisionName"      "start"             
#> [19] "finish"             "start_longitude"    "start_latitude"    
#> [22] "finish_longitude"   "finish_latitude"    "crow_fly_distance" 
#> [25] "event"              "whence"             "speed"             
#> [28] "itinerary"          "plan"               "note"              
#> [31] "length"             "west"               "south"             
#> [34] "east"               "north"              "leaving"           
#> [37] "arriving"           "grammesCO2saved"    "calories"          
#> [40] "edition"            "gradient_segment"   "elevation_change"  
#> [43] "gradient_smooth"    "geometry"          
json2sf_cs(readLines(f), id = 1, segments = TRUE, cols_to_keep = "quietness")
#> Simple feature collection with 14 features and 1 field
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -1.5482 ymin: 53.79314 xmax: -1.54408 ymax: 53.7966
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    quietness                       geometry
#> 1         50 LINESTRING (-1.54408 53.793...
#> 2         50 LINESTRING (-1.54526 53.793...
#> 3         75 LINESTRING (-1.54687 53.793...
#> 4         75 LINESTRING (-1.54682 53.793...
#> 5         50 LINESTRING (-1.5465 53.7950...
#> 6         60 LINESTRING (-1.54649 53.795...
#> 7         70 LINESTRING (-1.54713 53.796...
#> 8         90 LINESTRING (-1.54702 53.796...
#> 9         85 LINESTRING (-1.54723 53.796...
#> 10        85 LINESTRING (-1.54731 53.796...
# save result from the API call to journey.json
# res_json = journey(from_point, to_point, silent = FALSE, save_raw = TRUE)
# jsonlite::write_json(res_json, "inst/extdata/journey_short.json")
# f = "inst/extdata/journey_short.json"
f = system.file(package = "cyclestreets", "extdata/journey_short.json")
obj = jsonlite::read_json(f, simplifyVector = TRUE)
# Inclusion of "start_longitude" leads to the additional ProvisionName1 colum:
cols = c("name", "distances", "provisionName")
json2sf_cs(readLines(f), id = 1, segments = TRUE, cols_to_keep = cols)
#> Simple feature collection with 1 feature and 3 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -8.80639 ymin: 52.50692 xmax: -8.80403 ymax: 52.51329
#> Geodetic CRS:  WGS 84
#>            name distances     provisionName                       geometry
#> 1 Un-named link       769 Unclassified road LINESTRING (-8.80639 52.506...