-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update json code - see a-b-street/docs#19
- Loading branch information
1 parent
deb043c
commit c587267
Showing
3 changed files
with
26 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Aim: generate a minimal dataset corresponding to a minimal example scenario | ||
json = jsonlite::read_json("inst/extdata/minimal_scenario2.json") | ||
json_df = jsonlite::read_json("inst/extdata/minimal_scenario.json", simplifyVector = TRUE) | ||
# Try importing the data into abstreet | ||
json_df$people$trips[[1]] | ||
data.table::rbindlist(json_df$people$trips) | ||
trip_data = dplyr::bind_rows(json_df$people$trips, .id = "id") | ||
|
||
# code below could be generalised to a json_to_sf() function | ||
linestrings = od::odc_to_sf(cbind( | ||
trip_data$origin$Position$longitude, | ||
trip_data$origin$Position$latitude, | ||
trip_data$destination$Position$longitude, | ||
trip_data$destination$Position$latitude | ||
)) | ||
mapview::mapview(linestrings) | ||
od::odc_to_sf() | ||
sf_data = | ||
sf_linestring = sf::st_sf( | ||
|
||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters