-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsession3B_talk4.html
602 lines (462 loc) · 27 KB
/
session3B_talk4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<title>osmextract: An R package to download, convert, and import large OpenStreetMap datasets</title>
<meta charset="utf-8" />
<meta name="author" content="Andrea Gilardi and Robin Lovelace" />
<script src="Gilardi-osmextract-141_b_files/header-attrs/header-attrs.js"></script>
<link href="Gilardi-osmextract-141_b_files/remark-css/useR.css" rel="stylesheet" />
<link href="Gilardi-osmextract-141_b_files/remark-css/useR-fonts.css" rel="stylesheet" />
<script src="Gilardi-osmextract-141_b_files/htmlwidgets/htmlwidgets.js"></script>
<script src="Gilardi-osmextract-141_b_files/jquery/jquery.min.js"></script>
<link href="Gilardi-osmextract-141_b_files/leaflet/leaflet.css" rel="stylesheet" />
<script src="Gilardi-osmextract-141_b_files/leaflet/leaflet.js"></script>
<link href="Gilardi-osmextract-141_b_files/leafletfix/leafletfix.css" rel="stylesheet" />
<script src="Gilardi-osmextract-141_b_files/proj4/proj4.min.js"></script>
<script src="Gilardi-osmextract-141_b_files/Proj4Leaflet/proj4leaflet.js"></script>
<link href="Gilardi-osmextract-141_b_files/rstudio_leaflet/rstudio_leaflet.css" rel="stylesheet" />
<script src="Gilardi-osmextract-141_b_files/leaflet-binding/leaflet.js"></script>
<script src="Gilardi-osmextract-141_b_files/leaflet-providers/leaflet-providers_1.9.0.js"></script>
<script src="Gilardi-osmextract-141_b_files/leaflet-providers-plugin/leaflet-providers-plugin.js"></script>
<script src="Gilardi-osmextract-141_b_files/clipboard/setClipboardText.js"></script>
</head>
<body>
<textarea id="source">
class: center, middle, inverse, title-slide
# osmextract: An R package to download, convert, and import large OpenStreetMap datasets
### Andrea Gilardi and Robin Lovelace
### University of Milano - Bicocca and University of Leeds
### 2021/07/06
---
<style type="text/css">
.pull-left-40 {
float: left;
width: 39%;
margin-top: -30px;
}
.pull-right-60 {
float: right;
width: 57%;
margin-top: -150px;
}
.large { font-size: 120% }
.small { font-size: 70% }
</style>
## The initial development
.large[
.pull-left[
`osmextract` 📦 is the results of an international research collaboration:
```r
locations = rbind(
osmextract:::oe_search("Leeds"),
osmextract:::oe_search("Milan"),
osmextract::oe_search("Github") # ???
osmextract:::oe_search("Toulouse")
)
tmap_leaflet(
qtm(
locations,
symbols.size = 2,
symbols.col = "black",
basemaps = providers$OpenStreetMap
)
)
```
]
]
.pull-right[
<div id="htmlwidget-691ee6cc8259838453a1" style="width:504px;height:504px;" class="leaflet html-widget"></div>
<script type="application/json" data-for="htmlwidget-691ee6cc8259838453a1">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"createMapPane","args":["tmap401",401]},{"method":"createMapPane","args":["tmap402",402]},{"method":"addProviderTiles","args":["OpenStreetMap",null,"OpenStreetMap",{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"pane":"tilePane"}]},{"method":"addCircles","args":[[53.7974185,45.4668,43.6044622],[-1.5437941,9.1905,1.4442469],[32718.6362583391,32718.6362583391,32718.6362583391],["X258136264","X317180606","X257187066"],"locations",{"interactive":true,"className":"","pane":"tmap401","stroke":true,"color":"#666666","weight":1,"opacity":0.5,"fill":true,"fillColor":["#000000","#000000","#000000"],"fillOpacity":[1,1,1]},["<style> div.leaflet-popup-content {width:auto !important;overflow-y:auto; overflow-x:hidden;}<\/style><div style=\"max-height:25em;padding-right:0px;\"><table>\n\t\t\t <thead><tr><th colspan=\"2\"><b>258136264<\/b><\/th><\/thead><\/tr><tr><td style=\"color: #888888;\"><nobr>place_id<\/nobr><\/td><td align=\"right\"><nobr>258 mln<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_type<\/nobr><\/td><td align=\"right\"><nobr>relation<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_id<\/nobr><\/td><td align=\"right\"><nobr>118,362<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>display_name<\/nobr><\/td><td align=\"right\"><nobr>Leeds, West Yorkshire, Yorkshire and the Humber, England, United Kingdom<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>place_rank<\/nobr><\/td><td align=\"right\"><nobr>16<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>category<\/nobr><\/td><td align=\"right\"><nobr>boundary<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>type<\/nobr><\/td><td align=\"right\"><nobr>administrative<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>importance<\/nobr><\/td><td align=\"right\"><nobr>0.739<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>icon<\/nobr><\/td><td align=\"right\"><nobr>https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png<\/nobr><\/td><\/tr><\/table><\/div>","<style> div.leaflet-popup-content {width:auto !important;overflow-y:auto; overflow-x:hidden;}<\/style><div style=\"max-height:25em;padding-right:0px;\"><table>\n\t\t\t <thead><tr><th colspan=\"2\"><b>317180606<\/b><\/th><\/thead><\/tr><tr><td style=\"color: #888888;\"><nobr>place_id<\/nobr><\/td><td align=\"right\"><nobr>317 mln<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_type<\/nobr><\/td><td align=\"right\"><nobr>relation<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_id<\/nobr><\/td><td align=\"right\"><nobr>44,915<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>display_name<\/nobr><\/td><td align=\"right\"><nobr>Milano, Lombardia, Italia<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>place_rank<\/nobr><\/td><td align=\"right\"><nobr>16<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>category<\/nobr><\/td><td align=\"right\"><nobr>boundary<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>type<\/nobr><\/td><td align=\"right\"><nobr>administrative<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>importance<\/nobr><\/td><td align=\"right\"><nobr>0.839<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>icon<\/nobr><\/td><td align=\"right\"><nobr>https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png<\/nobr><\/td><\/tr><\/table><\/div>","<style> div.leaflet-popup-content {width:auto !important;overflow-y:auto; overflow-x:hidden;}<\/style><div style=\"max-height:25em;padding-right:0px;\"><table>\n\t\t\t <thead><tr><th colspan=\"2\"><b>257187066<\/b><\/th><\/thead><\/tr><tr><td style=\"color: #888888;\"><nobr>place_id<\/nobr><\/td><td align=\"right\"><nobr>257 mln<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_type<\/nobr><\/td><td align=\"right\"><nobr>relation<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>osm_id<\/nobr><\/td><td align=\"right\"><nobr>35,738<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>display_name<\/nobr><\/td><td align=\"right\"><nobr>Toulouse, Haute-Garonne, Occitanie, France métropolitaine, France<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>place_rank<\/nobr><\/td><td align=\"right\"><nobr>16<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>category<\/nobr><\/td><td align=\"right\"><nobr>boundary<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>type<\/nobr><\/td><td align=\"right\"><nobr>administrative<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>importance<\/nobr><\/td><td align=\"right\"><nobr>0.778<\/nobr><\/td><\/tr><tr><td style=\"color: #888888;\"><nobr>icon<\/nobr><\/td><td align=\"right\"><nobr>https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png<\/nobr><\/td><\/tr><\/table><\/div>"],null,["258136264","317180606","257187066"],{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null,null]},{"method":"addLayersControl","args":[[],"locations",{"collapsed":true,"autoZIndex":true,"position":"topleft"}]},{"method":"addScaleBar","args":[{"maxWidth":100,"metric":true,"imperial":false,"updateWhenIdle":true,"position":"bottomright"}]}],"limits":{"lat":[43.6044622,53.7974185],"lng":[-1.5437941,9.1905]},"fitBounds":[43.6044622,-1.5437941,53.7974185,9.1905,[]]},"evals":[],"jsHooks":{"render":[{"code":"function(el, x, data) {\n return (\n function(el, x, data) {\n // get the leaflet map\n var map = this; //HTMLWidgets.find('#' + el.id);\n // we need a new div element because we have to handle\n // the mouseover output separately\n // debugger;\n function addElement () {\n // generate new div Element\n var newDiv = $(document.createElement('div'));\n // append at end of leaflet htmlwidget container\n $(el).append(newDiv);\n //provide ID and style\n newDiv.addClass('lnlt');\n newDiv.css({\n 'position': 'relative',\n 'bottomleft': '0px',\n 'background-color': 'rgba(255, 255, 255, 0.7)',\n 'box-shadow': '0 0 2px #bbb',\n 'background-clip': 'padding-box',\n 'margin': '0',\n 'padding-left': '5px',\n 'color': '#333',\n 'font': '9px/1.5 \"Helvetica Neue\", Arial, Helvetica, sans-serif',\n 'z-index': '700',\n });\n return newDiv;\n }\n\n\n // check for already existing lnlt class to not duplicate\n var lnlt = $(el).find('.lnlt');\n\n if(!lnlt.length) {\n lnlt = addElement();\n\n // grab the special div we generated in the beginning\n // and put the mousmove output there\n\n map.on('mousemove', function (e) {\n if (e.originalEvent.ctrlKey) {\n if (document.querySelector('.lnlt') === null) lnlt = addElement();\n lnlt.text(\n ' lon: ' + (e.latlng.lng).toFixed(5) +\n ' | lat: ' + (e.latlng.lat).toFixed(5) +\n ' | zoom: ' + map.getZoom() +\n ' | x: ' + L.CRS.EPSG3857.project(e.latlng).x.toFixed(0) +\n ' | y: ' + L.CRS.EPSG3857.project(e.latlng).y.toFixed(0) +\n ' | epsg: 3857 ' +\n ' | proj4: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs ');\n } else {\n if (document.querySelector('.lnlt') === null) lnlt = addElement();\n lnlt.text(\n ' lon: ' + (e.latlng.lng).toFixed(5) +\n ' | lat: ' + (e.latlng.lat).toFixed(5) +\n ' | zoom: ' + map.getZoom() + ' ');\n }\n });\n\n // remove the lnlt div when mouse leaves map\n map.on('mouseout', function (e) {\n var strip = document.querySelector('.lnlt');\n if( strip !==null) strip.remove();\n });\n\n };\n\n //$(el).keypress(67, function(e) {\n map.on('preclick', function(e) {\n if (e.originalEvent.ctrlKey) {\n if (document.querySelector('.lnlt') === null) lnlt = addElement();\n lnlt.text(\n ' lon: ' + (e.latlng.lng).toFixed(5) +\n ' | lat: ' + (e.latlng.lat).toFixed(5) +\n ' | zoom: ' + map.getZoom() + ' ');\n var txt = document.querySelector('.lnlt').textContent;\n console.log(txt);\n //txt.innerText.focus();\n //txt.select();\n setClipboardText('\"' + txt + '\"');\n }\n });\n\n }\n ).call(this.getMap(), el, x, data);\n}","data":null}]}}</script>
]
???
Something about us and how we came to work on the project
---
## What is OpenStreetMap ?
.large[
- OpenStreetMap (OSM) is an online database that provides open-access geographic and rich attribute data worldwide.
- OSM is the ‘Wikipedia of maps’, with data continuously uploaded by millions of users.
- OSM data represent a wide range of physical and, in particular, human features, including roads, rivers, buildings, coastal lines, political and administrative boundaries.
- OSM data are used by several public and private agencies in several fields like transport planning, road safety analysis, and disaster response.
]
---
## Install `osmextract`
.large[
The stable version of the package can be installed from [CRAN](https://cran.r-project.org/web/packages/osmextract/index.html) using the following command:
```r
install.packages("osmextract")
```
The development verson can be installed from [github](https://github.com/ropensci/osmextract) as follows:
```r
remotes::install_github("ropensci/osmextract")
```
The default behaviour of all functions in **`osmextract`** is to save the data into a temporary directory that is erased every time you restart `R`.
You can set a persistent directory using the following code:
```r
usethis::edit_r_environ()
# Add a line containing: OSMEXT_DOWNLOAD_DIRECTORY=/path/to/save/files
```
]
???
Explain differences between CRAN and github version
Mention the persistent directory stuff.
---
## Load the 📦
.large[
Loading the package raises an important message regarding the license associated with OSM data
```r
library("osmextract")
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
## Check the package website, https://docs.ropensci.org/osmextract/, for more details.
```
The function defined in our package return `sf` objects; hence, we will also load the package with the same name:
```r
library("sf")
## Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1
```
]
???
A few details on OSM data + a few words about sf v1.0
---
## OSM data providers
.large[
OSM data can be obtained mainly in two ways:
1. querying OSM servers using the Overpass API;
2. using pre-formatted extracts stored by external providers (such as [Geofabrik](http://www.geofabrik.de/data/download.html)).
The popular `R` package **`osmdata`** defines a set of routines to quickly process OSM data downloaded from Overpass web server, while our package introduces a set of functions to work with OSM extracts directly from `R`.
At the moment, we support the following external providers:
```r
oe_providers(quiet = TRUE)
## available_providers database_name number_of_zones number_of_fields
## 1 geofabrik geofabrik_zones 430 14
## 2 bbbike bbbike_zones 235 10
## 3 openstreetmap_fr openstreetmap_fr_zones 903 6
```
]
---
## The backbone of `osmextract`
.large[
The package is composed of the following main functions:
1. **`oe_match()`**: Match an input place with one of the files stored by the OSM providers;
2. **`oe_download()`**: Download the chosen file;
3. **`oe_vectortranslate()`**: Convert between `.pbf` and `.gpkg` formats;
4. **`oe_read()`**: Read `.pbf` and `.gpkg` files;
5. **`oe_get()`**: Match, download, (vector)translate, and import data, all in one step.
For simplicity, we will focus only on **`oe_get()`** and we refer to the introductory vignette for more details.
Let's see a few examples!
]
???
Explain the workflow
---
## `oe_get()`: Examples
.large[
**`oe_get()`** can be used to match an input place with one of the OSM extracts and import the corresponding data. For example:
```r
isle_of_wight <- oe_get("Isle of Wight")
## The input place was matched with: Isle of Wight
## File downloaded!
## Start with the vectortranslate operations on the input file!
## 0...10...20...30...40...50...60...70...80...90...100 - done.
## Finished the vectortranslate operations on the input file!
## Reading layer `lines' from data source
## `/private/var/folders/lm/44wm2r8n6hj3sdq011h_429w0000gn/T/RtmpuGhdPN/geofabrik_isle-of-wight-latest.gpkg'
## using driver `GPKG'
## Simple feature collection with 47723 features and 9 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -5.715479 ymin: 43.35489 xmax: 1.92832 ymax: 51.16517
## Geodetic CRS: WGS 84
```
]
---
## `oe_get()`: Examples
.large[
We can also perform spatial matching using lon/lat coordinates (implicit CRS is `EPSG:4326`):
```r
isle_of_wight <- oe_get(c(-1.305, 50.694))
## The input place was matched with Isle of Wight.
## The chosen file was already detected in the download directory. Skip downloading.
## The corresponding gpkg file was already detected. Skip vectortranslate operations.
## Reading layer `lines' from data source
## `/private/var/folders/lm/44wm2r8n6hj3sdq011h_429w0000gn/T/RtmpuGhdPN/geofabrik_isle-of-wight-latest.gpkg'
## using driver `GPKG'
## Simple feature collection with 47723 features and 9 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -5.715479 ymin: 43.35489 xmax: 1.92832 ymax: 51.16517
## Geodetic CRS: WGS 84
```
The same operation can be performed using `sf` or `sfc` objects with any CRS.
]
---
## `oe_get()`: Examples
.large[
If the input place cannot be matched with any OSM extract, then **`oe_get()`** calls the Nominatim API (via **`oe_match()`**) to geolocate the input and perform a spatial matching operation.
For example:
```r
oe_match("Olginate, Italy")
## No exact match found for place = Olginate, Italy and provider = geofabrik. Best match is Great Britain.
## Checking the other providers.
## No exact match found in any OSM provider data. Searching for the location online.
## The input place was matched with Nord-Ovest.
## $url
## [1] "https://download.geofabrik.de/europe/italy/nord-ovest-latest.osm.pbf"
##
## $file_size
## [1] 433707500
```
]
---
## `oe_get()`: Examples
.large[
.pull-left-40[
The most important argument in **`oe_get()`** is probably `vectortranslate_options`.
We can tune the operations run during the vectortranslate process.
```r
isle_of_wight <- oe_get(
place = "Isle of Wight",
vectortranslate_options = c(
"-t_srs", "EPSG:27700",
"-where", "highway IS NOT NULL"
),
quiet = TRUE
)
```
]
]
.pull-right-60[
<img src="https://user-images.githubusercontent.com/22221146/123111477-3d366280-d43d-11eb-90ec-92846c9cfc23.png" alt="Map of the road network in the Isle of Wight. The road segments are colored according to the road type"; width="118%" style="display: block; margin: auto; margin-top: 140px; margin-left: -40px"/>
]
---
## `oe_get()`: Examples
.large[
.pull-left-40[
We can also apply SQL-like queries:
```r
isle_of_wight_small <- oe_get(
place = "Isle of Wight",
vectortranslate_options = c(
"-t_srs", "EPSG:27700",
"-where", "highway IN
('primary', 'secondary',
'tertiary')"
),
quiet = TRUE
)
```
]
]
.pull-right-60[
<img src="https://user-images.githubusercontent.com/22221146/123111691-65be5c80-d43d-11eb-87ff-cced0e52f003.png" alt="Map of the road network in the Isle of Wight highlighting primary, secondary, and tertiary roads."; width="118%" style="display: block; margin: auto; margin-top: 140px; margin-left: -40px"/>
]
---
## Most important features introduced in v0.3
.large[
A few weeks ago we release version 0.3 that introduces several new features:
- Two new arguments in **`oe_get()`** named `boundary` and `boundary-type` for spatial filter operations;
- The **`oe_match_pattern()`** function compares the input against all available OSM providers;
- The **`oe_get_keys()`** function can be used to display all keys and corresponding values.
- A logo 😍:
<img src="https://docs.ropensci.org/osmextract/reference/figures/logo.svg" width = "35%" style="display: block; margin: auto; margin-top: -120px;"/>
]
???
TESTME
---
## Boundary
.large[
.pull-left-40[
The `boundary` argument can be used to apply a spatial filter that selects all roads intersecting a given polygon
```r
newport <- st_sfc(
st_point(c(-1.29089, 50.6971)),
crs = 4326
)
newport <- st_buffer(newport, 5000)
isle_of_wight_spat <- oe_get(
place = "Isle of Wight",
quiet = TRUE,
boundary = newport,
vectortranslate_options = c(
"-where", "highway IS NOT NULL"
)
)
```
]
]
.pull-right-60[
<img src="https://user-images.githubusercontent.com/22221146/123111710-6951e380-d43d-11eb-9ab1-7c9baa69cc7d.png" alt="Map of the road network in the Isle of Wight. The segments intersecting a circular buffer around Newport are highlighted."; width="118%" style="display: block; margin: auto; margin-top: 140px; margin-left: -40px"/>
]
---
## Boundary type
.large[
.pull-left-40[
The `boundary-type` argument can be used to select the type of spatial filter. The `clipsrc` option can be used to clip the geometries.
```r
isle_of_wight_clip <- oe_get(
place = "Isle of Wight",
quiet = TRUE,
boundary = newport,
boundary_type = "clipsrc",
vectortranslate_options = c(
"-where", "highway IS NOT NULL",
"-nlt", "PROMOTE_TO_MULTI"
)
)
```
]
]
.pull-right-60[
<img src="https://user-images.githubusercontent.com/22221146/123111705-6820b680-d43d-11eb-898a-16202c40ce29.png" alt="Map of the road network in the Isle of Wight. The segments intersecting a circular buffer around Newport are highlighted. The segments are also clipped."; width="118%" style="display: block; margin: auto; margin-top: 140px; margin-left: -40px"/>
]
---
## What can you do with it? I
.pull-left[
.large[
Speed limits of Roads in London:
]
<div style="width: 550px; height: 385px; overflow: hidden;">
<img src="https://user-images.githubusercontent.com/1825120/122961671-870b4400-d37c-11eb-9ab7-6420b1aa8b07.png" alt="Roads in London colored according to the speed limit."; width= 650px height= 425px; style="display: block; margin: auto; margin-top: -15px"/>
</div>
]
.pull-right[
.large[
Classification of cycleways in a region of Norway
]
<img src="https://user-images.githubusercontent.com/1825120/122961289-2b40bb00-d37c-11eb-93ef-42b0e7639926.png" alt="Cycleways in a region of Norway colored according to the type."; width="85%" style="display: block; margin: auto;"/>
]
---
## What can you do with it? II
.pull-left[
Road safety analysis in Leeds:
<img src="https://user-images.githubusercontent.com/22221146/123111721-6b1ba700-d43d-11eb-8a08-c75b3655ae97.png" alt="Estimate of car crashes rate for road segments in Leeds."; width = "100%" style="display: block; margin: auto;"/>
]
.pull-right[
Analysis of Ambulance interventions in Milan:
<img src="https://user-images.githubusercontent.com/22221146/123111730-6c4cd400-d43d-11eb-8e79-b9b3ecf82877.png" alt="Estimate of ambulance interventions rates in the road network of Milan."; width = "100%" style="display: block; margin: auto;"/>
]
---
## Thanks!
### Thank you for attending this presentation. Thanks to `rOpenSci` for reviewing our package and all `R` users that helped us develop it.
### How do you plan to use OSM extracts? Let us know!
</textarea>
<style data-target="print-only">@media screen {.remark-slide-container{display:block;}.remark-slide-scaler{box-shadow:none;}}</style>
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
<script src="https://platform.twitter.com/widgets.js"></script>
<script src="macro.js"></script>
<script>var slideshow = remark.create({
"highlightStyle": "github",
"highlightLines": true,
"countIncrementalSlides": false,
"ratio": "16:9"
});
if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
window.dispatchEvent(new Event('resize'));
});
(function(d) {
var s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
if (!r) return;
s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
d.head.appendChild(s);
})(document);
(function(d) {
var el = d.getElementsByClassName("remark-slides-area");
if (!el) return;
var slide, slides = slideshow.getSlides(), els = el[0].children;
for (var i = 1; i < slides.length; i++) {
slide = slides[i];
if (slide.properties.continued === "true" || slide.properties.count === "false") {
els[i - 1].className += ' has-continuation';
}
}
var s = d.createElement("style");
s.type = "text/css"; s.innerHTML = "@media print { .has-continuation { display: none; } }";
d.head.appendChild(s);
})(document);
// delete the temporary CSS (for displaying all slides initially) when the user
// starts to view slides
(function() {
var deleted = false;
slideshow.on('beforeShowSlide', function(slide) {
if (deleted) return;
var sheets = document.styleSheets, node;
for (var i = 0; i < sheets.length; i++) {
node = sheets[i].ownerNode;
if (node.dataset["target"] !== "print-only") continue;
node.parentNode.removeChild(node);
}
deleted = true;
});
})();
(function() {
"use strict"
// Replace <script> tags in slides area to make them executable
var scripts = document.querySelectorAll(
'.remark-slides-area .remark-slide-container script'
);
if (!scripts.length) return;
for (var i = 0; i < scripts.length; i++) {
var s = document.createElement('script');
var code = document.createTextNode(scripts[i].textContent);
s.appendChild(code);
var scriptAttrs = scripts[i].attributes;
for (var j = 0; j < scriptAttrs.length; j++) {
s.setAttribute(scriptAttrs[j].name, scriptAttrs[j].value);
}
scripts[i].parentElement.replaceChild(s, scripts[i]);
}
})();
(function() {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (/^(https?:)?\/\//.test(links[i].getAttribute('href'))) {
links[i].target = '_blank';
}
}
})();
// adds .remark-code-has-line-highlighted class to <pre> parent elements
// of code chunks containing highlighted lines with class .remark-code-line-highlighted
(function(d) {
const hlines = d.querySelectorAll('.remark-code-line-highlighted');
const preParents = [];
const findPreParent = function(line, p = 0) {
if (p > 1) return null; // traverse up no further than grandparent
const el = line.parentElement;
return el.tagName === "PRE" ? el : findPreParent(el, ++p);
};
for (let line of hlines) {
let pre = findPreParent(line);
if (pre && !preParents.includes(pre)) preParents.push(pre);
}
preParents.forEach(p => p.classList.add("remark-code-has-line-highlighted"));
})(document);</script>
<script>
slideshow._releaseMath = function(el) {
var i, text, code, codes = el.getElementsByTagName('code');
for (i = 0; i < codes.length;) {
code = codes[i];
if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
text = code.textContent;
if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
/^\$\$(.|\s)+\$\$$/.test(text) ||
/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
code.outerHTML = code.innerHTML; // remove <code></code>
continue;
}
}
i++;
}
};
slideshow._releaseMath(document);
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
if (location.protocol !== 'file:' && /^https?:/.test(script.src))
script.src = script.src.replace(/^https?:/, '');
document.getElementsByTagName('head')[0].appendChild(script);
})();
</script>
</body>
</html>