Skip to content

Commit

Permalink
update readme plots
Browse files Browse the repository at this point in the history
update readme plots by using a wide range of OD pairs and tmap styles
  • Loading branch information
natesheehan committed Aug 18, 2021
1 parent fdc059d commit 726143b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
14 changes: 8 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ knitr::opts_chunk$set(
<!-- badges: end -->

<img src="https://user-images.githubusercontent.com/22789869/129973263-5fc74ae3-ed17-4155-9a8c-7f382f7796cc.png" align="left" height="164px" width="164px" margin="10%" />

--
**The goal of abstr is to provide an R interface to the [A/B Street](https://github.com/a-b-street/abstreet#ab-street) transport planning/simulation game.
Currently it provides a way to convert aggregated origin-destination data, combined with data on buildings representing origin and destination locations, into `.json` files that can be directly imported into the A/B Street city simulation.**


See the formats page in the [A/B Street documentation](https://a-b-street.github.io/docs/tech/dev/formats/scenarios.html) for details of the schema that the package outputs.

## Installation
Expand All @@ -48,7 +47,8 @@ The input datasets are illustrated in the plots below, which show example data s
library(abstr)
library(tmap) # for map making
tm_shape(montlake_zones) + tm_polygons(col = "grey") +
tm_shape(montlake_buildings) + tm_polygons(col = "blue")
tm_shape(montlake_buildings) + tm_polygons(col = "blue") +
tm_style("classic")
```

The map above is a graphical representation of the Montlake residential neighborhood in central Seattle, Washington. Here, `montlake_zones` represents neighborhood residential zones declared by Seattle local government and `montlake_buildings` being the accumulation of buildings listed in <a link href="https://www.openstreetmap.org/#map=5/54.910/-3.432"> OpenStreetMap</a>
Expand All @@ -67,7 +67,7 @@ While the OD data contains information on origin and destination zone, `ab_scena

```{r message=FALSE,warning=FALSE}
set.seed(42)
montlake_od_minimal = montlake_od[sample(nrow(montlake_od), size = 3), ]
montlake_od_minimal = subset(montlake_od, o_id == "373" |o_id == "402" | o_id == "281" | o_id == "588" | o_id == "301" | o_id == "314")
output_sf = ab_scenario(
od = montlake_od_minimal,
zones = montlake_zones,
Expand All @@ -84,8 +84,10 @@ output_sf = ab_scenario(
The `output_sf` object created above can be further transformed to match [A/B Street's schema](https://a-b-street.github.io/docs/tech/dev/formats/scenarios.html) and visualised in A/B Street, or visualised in R (using the `tmap` package in the code chunk below):

```{r outputplot}
tm_shape(output_sf) + tmap::tm_lines(col = "mode") +
tm_shape(montlake_zones) + tmap::tm_borders()
tm_shape(output_sf) + tmap::tm_lines(col = "mode", lwd = .8, lwd.legeld.col = "black") +
tm_shape(montlake_zones) + tmap::tm_borders(lwd = 1.2, col = "gray") +
tm_text("id", size = 0.6) +
tm_style("cobalt")
```

Each line in the plot above represents a single trip, with the color representing each transport mode. Moreover, each trip is configured with an associated departure time, that can be represented in A/B Street.
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![R-CMD-check](https://github.com/a-b-street/abstr/workflows/R-CMD-check/badge.svg)](https://github.com/a-b-street/abstr/actions)
<!-- badges: end -->

<img src="https://user-images.githubusercontent.com/22789869/129973263-5fc74ae3-ed17-4155-9a8c-7f382f7796cc.png" align="left" height="164px" width="164px" margin="10%" />
## <img src="https://user-images.githubusercontent.com/22789869/129973263-5fc74ae3-ed17-4155-9a8c-7f382f7796cc.png" align="left" height="164px" width="164px" margin="10%" />

**The goal of abstr is to provide an R interface to the [A/B
Street](https://github.com/a-b-street/abstreet#ab-street) transport
Expand Down Expand Up @@ -46,7 +46,8 @@ library(abstr)
library(tmap) # for map making
#> Warning: package 'tmap' was built under R version 4.0.5
tm_shape(montlake_zones) + tm_polygons(col = "grey") +
tm_shape(montlake_buildings) + tm_polygons(col = "blue")
tm_shape(montlake_buildings) + tm_polygons(col = "blue") +
tm_style("classic")
```

<div class="figure">
Expand Down Expand Up @@ -98,7 +99,7 @@ between three pairs of zones, to illustrate the process:

``` r
set.seed(42)
montlake_od_minimal = montlake_od[sample(nrow(montlake_od), size = 3), ]
montlake_od_minimal = subset(montlake_od, o_id == "373" |o_id == "402" | o_id == "281" | o_id == "588" | o_id == "301" | o_id == "314")
output_sf = ab_scenario(
od = montlake_od_minimal,
zones = montlake_zones,
Expand All @@ -119,8 +120,10 @@ and visualised in A/B Street, or visualised in R (using the `tmap`
package in the code chunk below):

``` r
tm_shape(output_sf) + tmap::tm_lines(col = "mode") +
tm_shape(montlake_zones) + tmap::tm_borders()
tm_shape(output_sf) + tmap::tm_lines(col = "mode", lwd = .8, lwd.legeld.col = "black") +
tm_shape(montlake_zones) + tmap::tm_borders(lwd = 1.2, col = "gray") +
tm_text("id", size = 0.6) +
tm_style("cobalt")
```

<img src="man/figures/README-outputplot-1.png" width="100%" />
Expand Down
Binary file modified man/figures/README-input-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-outputplot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 726143b

Please sign in to comment.