ab_sf {abstr}R Documentation

Convert JSON representation of trips from A/B Street into an 'sf' object

Description

This function takes a path to a JSON file representing an A/B Street scenario, or an R representation of the JSON in a list, and returns an sf object with the same structure as objects returned by ab_scenario().

Usage

ab_sf(json)

Arguments

json

Character string or list representing a JSON file or list that has been read into R and converted to a data frame.

Details

Note: the departure time in seconds is divided by 10000 on conversion to represent seconds, which are easier to work with that 10,000th of a second units.

Value

An sf data frame representing travel behaviour scenarios from, and which can be fed into, A/B Street. Contains the following columns: person (the ID of each agent in the simulation), departure (seconds after midnight of the travel starting), mode (the mode of transport, being Walk, Bike, Transit and Drive), purpose (what the trip was for, e.g. Work), and geometry (a linestring showing the start and end point of the trip/stage).

Examples

file_name = system.file("extdata/minimal_scenario2.json", package = "abstr")
ab_sf(file_name)
json = jsonlite::read_json(file_name, simplifyVector = TRUE)
ab_sf(json)

[Package abstr version 0.4.1 Index]