Skip to content

Commit

Permalink
Deploy commit: improves 09 (#1125) 8e5af76
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Sep 25, 2024
1 parent 557fd28 commit feacb47
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 177 deletions.
171 changes: 85 additions & 86 deletions 09-mapping.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion 13-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ This is done using the publicly available OSRM service with the **stplanr** func
``` r
routes_short = route(l = desire_lines_short, route_fun = route_osrm,
osrm.profile = "bike")
#> <simpleError in open.connection(con, "rb"): cannot open the connection to 'https://routing.openstreetmap.de/routed-bike/route/v1/driving/-2.62449584285587,51.5083596238341;-2.66873099020632,51.5135817785512?alternatives=false&geometries=geojson&steps=false&overview=full'>
```

The output is `routes_short`, an `sf` object representing routes on the transport network\index{network} that are suitable for cycling (according to the OSRM routing engine at least), one for each desire line.
Expand Down Expand Up @@ -569,7 +570,7 @@ routes_short_scenario = routes_short |>
mutate(bicycle = bicycle + car_driver * uptake,
car_driver = car_driver * (1 - uptake))
sum(routes_short_scenario$bicycle) - sum(routes_short$bicycle)
#> [1] 3850
#> [1] 558
```

Having created a scenario in which approximately 4000 trips have switched from driving to cycling, we can now model where this updated modeled cycling activity will take place.
Expand Down
172 changes: 85 additions & 87 deletions adv-map.html

Large diffs are not rendered by default.

Binary file modified figures/circle-intersection-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 figures/cycleways-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 figures/points-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 figures/rnetvis-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 figures/rnetvis-2.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 figures/routes-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 figures/wayssln-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion search.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions transport.html
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ <h3>
This is done using the publicly available OSRM service with the <strong>stplanr</strong> functions <code><a href="https://docs.ropensci.org/stplanr/reference/route.html">route()</a></code> and <code><a href="https://docs.ropensci.org/stplanr/reference/route_osrm.html">route_osrm()</a></code> in the code chunk below:</p>
<div class="sourceCode" id="cb455"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">routes_short</span> <span class="op">=</span> <span class="fu"><a href="https://docs.ropensci.org/stplanr/reference/route.html">route</a></span><span class="op">(</span>l <span class="op">=</span> <span class="va">desire_lines_short</span>, route_fun <span class="op">=</span> <span class="va">route_osrm</span>,</span>
<span> osrm.profile <span class="op">=</span> <span class="st">"bike"</span><span class="op">)</span></span></code></pre></div>
<span> osrm.profile <span class="op">=</span> <span class="st">"bike"</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;simpleError in open.connection(con, "rb"): cannot open the connection to 'https://routing.openstreetmap.de/routed-bike/route/v1/driving/-2.62449584285587,51.5083596238341;-2.66873099020632,51.5135817785512?alternatives=false&amp;geometries=geojson&amp;steps=false&amp;overview=full'&gt;</span></span></code></pre></div>
<p>The output is <code>routes_short</code>, an <code>sf</code> object representing routes on the transport network that are suitable for cycling (according to the OSRM routing engine at least), one for each desire line.
Note: calls to external routing engines such as in the command above only work with an internet connection (and sometimes an API key stored in an environment variable, although not in this case).
In addition to the columns contained in the <code>desire_lines</code> object, the new route dataset contains <code>distance</code> (referring to route distance this time) and <code>duration</code> columns (in seconds), which provide potentially useful extra information on the nature of each route.
Expand Down Expand Up @@ -651,7 +652,7 @@ <h2>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>bicycle <span class="op">=</span> <span class="va">bicycle</span> <span class="op">+</span> <span class="va">car_driver</span> <span class="op">*</span> <span class="va">uptake</span>,</span>
<span> car_driver <span class="op">=</span> <span class="va">car_driver</span> <span class="op">*</span> <span class="op">(</span><span class="fl">1</span> <span class="op">-</span> <span class="va">uptake</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/sum.html">sum</a></span><span class="op">(</span><span class="va">routes_short_scenario</span><span class="op">$</span><span class="va">bicycle</span><span class="op">)</span> <span class="op">-</span> <span class="fu"><a href="https://rdrr.io/r/base/sum.html">sum</a></span><span class="op">(</span><span class="va">routes_short</span><span class="op">$</span><span class="va">bicycle</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] 3850</span></span></code></pre></div>
<span><span class="co">#&gt; [1] 558</span></span></code></pre></div>
<p>Having created a scenario in which approximately 4000 trips have switched from driving to cycling, we can now model where this updated modeled cycling activity will take place.
For this, we will use the function <code><a href="https://docs.ropensci.org/stplanr/reference/overline.html">overline()</a></code> from the <strong>stplanr</strong> package.
The function breaks linestrings at junctions (were two or more linestring geometries meet), and calculates aggregate statistics for each unique route segment <span class="citation">(<a href="references.html#ref-morgan_travel_2020">Morgan and Lovelace 2020</a>)</span>, taking an object containing routes and the names of the attributes to summarize as the first and second argument:</p>
Expand Down

0 comments on commit feacb47

Please sign in to comment.