-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtutorial-2-points-lines-polygons.html
More file actions
1549 lines (1456 loc) · 168 KB
/
tutorial-2-points-lines-polygons.html
File metadata and controls
1549 lines (1456 loc) · 168 KB
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
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="JR Ferrer-Paris" />
<meta name="progressive" content="true" />
<meta name="allow-skip" content="true" />
<meta name="learnr-version-prerender" content="0.10.1.9019" />
<title>Geo-spatial tutorial: points / lines / polygons</title>
<!-- header-includes START -->
<!-- HEAD_CONTENT -->
<!-- header-includes END -->
<!-- HEAD_CONTENT -->
<!-- highlightjs -->
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<!-- taken from https://github.com/rstudio/rmarkdown/blob/de8a9c38618903627ca509f5401d50a0876079f7/inst/rmd/h/default.html#L293-L343 -->
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- end tabsets -->
</head>
<body>
<div class="pageContent band">
<div class="bandContent page">
<div class="topics">
<div id="section-welcome" class="section level2">
<h2>Welcome</h2>
<p>In this tutorial, you will learn some basic steps to start working with (geo)-spatial data in R. I prepared this tutorial as a intuitive “hands on” introduction, but I provide links for those interested in more background and theory.</p>
<p>We will cover how to:</p>
<ul>
<li>work with points, lines and polygons (vector data) using package <code>sf</code></li>
<li>apply basic spatial functions,</li>
<li>visualise spatial data with <code>ggplot</code></li>
</ul>
<div id="section-setup" class="section level3">
<h3>Setup</h3>
<p>I’ve preloaded the packages for this tutorial with</p>
<pre class="r"><code>library(sf)
library(units)
require(mapview)
require(RColorBrewer)</code></pre>
<p>Throughout this tutorial we will be using the pipe operator, <code>%>%</code>. You can use the pipe to rewrite multiple operations in a way that you can read left-to-right, top-to-bottom. We’ll use piping frequently because it considerably improves the readability of code. The pipe is a defining feature of the tidyverse, so we will load this set of packages as well.</p>
<pre class="r"><code>library(tidyverse)</code></pre>
<p>The tidyverse package also includes <code>ggplot2</code>, which allow us to create static maps in a similar modular fashion, but using the <code>+</code> operator instead of the pipe.</p>
<p>We will use the <code>franconia</code>, <code>breweries</code> and <code>trails</code> data sets from package <code>mapview</code>. These data sets are documented in <code>help(package=mapview)</code>.</p>
</div>
</div>
<div id="section-explore-points-with-sf" class="section level2">
<h2>Explore points with <code>sf</code></h2>
<p>For this tutorial we want to explore the surroundings of the University of Bayreuth, my <em>alma mater</em>.</p>
<p>I created a simple feature object using the functions we learned in the previous tutorial:</p>
<pre class="r"><code>UBT <- st_sf(data.frame(full_name='Universität Bayreuth',
url='https://uni-bayreuth.de/'),
crs=st_crs("EPSG:4326"),
geometry=st_sfc(
st_point(c(11.585833, 49.928889))))</code></pre>
<div id="section-welcome-to-franconia" class="section level3">
<h3>Welcome to Franconia</h3>
<p>There is not much we can do with one point, so we will look at a couple of data sets from this region, known as “Franken” in german or “Franconia” in other languages.</p>
</div>
<div id="section-the-breweries-dataset-in-franconia" class="section level3">
<h3>The <em>breweries</em> dataset in Franconia</h3>
<p>The best way to start our tour is to explore one of its main attractions: the breweries or Brauereien.</p>
<p>If you want to have an overview of a <code>sf</code> object in R, just type its name, click on the run button to show data and attributes of this object:</p>
<div class="tutorial-exercise" data-label="pointsex1" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>breweries</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>This is basically the same structure we have seen before, but with more points and several variables.</p>
<p>If you get a warning about and old-style crs object, you can simply update this with:</p>
<pre class="r"><code>st_crs(breweries) <- "EPSG:4326"</code></pre>
</div>
<div id="section-separate-data-from-geometry" class="section level3">
<h3>Separate data from geometry</h3>
<p>We can use the function <code>st_drop_geometry</code> to look at the data without the spatial component:</p>
<div class="tutorial-exercise" data-label="pointsex2" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>breweries %>% st_drop_geometry()</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
Or we can use <code>st_geometry</code> to look at the spatial component without the data:
<div class="tutorial-exercise" data-label="pointsex3" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>breweries %>% st_geometry()</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-plotting-geometry-and-data" class="section level3">
<h3>Plotting geometry and data</h3>
<p>There are many ways to explore data in spatial objects. We might be interested in non-spatial information, for example, how many types of beers are there in each brewery?</p>
<div class="tutorial-exercise" data-label="pointsex4" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>breweries %>% pull(number.of.types) %>% hist(main="Nr. of types of beers")</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section" class="section level3">
<h3></h3>
<p>But how do we know where are the breweries with the most types of beers?</p>
<p>Here we will select one variable from our object and use the default plot function for <em>sf</em> objects:</p>
<div class="tutorial-exercise" data-label="pointsex5" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>breweries %>% select(number.of.types) %>% plot(pch=19)</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>So, where would you go to have the largest selection of beers?</p>
</div>
<div id="section-distance-between-spatial-objects" class="section level3">
<h3>Distance between spatial objects</h3>
<p>You can imagine this is a question that was frequently asked in academic circles of the University. So let’s find the answer!</p>
<ul>
<li><p>First we will need to define what is the desired number of beers we expect. We can do this by filtering our spatial object based on a variable:</p>
<pre class="r"><code>selected_breweries <- breweries %>% filter(number.of.types>9)</code></pre></li>
<li><p>Then we want to know which one of these is nearest to our point of reference (UBT point):</p>
<pre class="r"><code>qry <- st_nearest_feature(UBT,selected_breweries)</code></pre></li>
<li><p>Now we can check the details for this record in the spatial object:</p>
<pre class="r"><code>selected_breweries %>% slice(qry)</code></pre></li>
<li><p>Finally we want to know the distance from the uni:</p>
<pre class="r"><code>st_distance(UBT,selected_breweries %>% slice(qry))</code></pre></li>
</ul>
</div>
<div id="section-section-1" class="section level3">
<h3></h3>
<p>Try running these lines of code, and see if you can answer the questions below:</p>
<div class="tutorial-exercise" data-label="pointsex6" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>selected_breweries <- breweries %>% filter(number.of.types>9)
qry <- st_nearest_feature(UBT,selected_breweries)
selected_breweries %>% slice(qry)
st_distance(UBT,selected_breweries %>% slice(qry))</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<div class="panel panel-default">
<div data-label="how_many_beers" class="tutorial-question panel-body">
<div id="how_many_beers-answer_container" class="shiny-html-output"></div>
<div id="how_many_beers-message_container" class="shiny-html-output"></div>
<div id="how_many_beers-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
</div>
<div id="section-section-2" class="section level3">
<h3></h3>
<p>We learned how to plot and query spatial and non-spatial information from a <code>sf</code> object, well done!</p>
<p>We will come back to the questions of plotting and querying spatial objects when we have a look at other types of spatial objects. Please continue to the next section.</p>
</div>
</div>
<div id="section-explore-polygons-with-sf" class="section level2">
<h2>Explore polygons with <code>sf</code></h2>
<p>So we know the basics of a <em>simple feature</em> object with points, and we have seen some simple ways to interact with this object. We will now learn that this structure will be very similar for other kind of geometries and this makes working with multiple objects very straightforward.</p>
<div id="section-the-municipalities-of-franconia-polygons" class="section level3">
<h3>The municipalities of Franconia (polygons)</h3>
<p>Let’s check one object that is already in one of the loaded data sets, it contains the boundaries of the municipalities of Franconia.</p>
<p>We will update the crs information to avoid warnings about an old-style crs object:</p>
<pre class="r"><code>st_crs(franconia) <- "EPSG:4326"</code></pre>
</div>
<div id="section-section-3" class="section level3">
<h3></h3>
<p>Check the information of this object, what is different from previous examples? what is similar?:</p>
<div class="tutorial-exercise" data-label="polysex1" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section-4" class="section level3">
<h3></h3>
<p>All <code>sf</code> objects have some common structure, regardless of how complex the spatial information is. The interesting feature here is that the geometry is composed of several polygons that can be associated with a single record in the data frame. Many spatial objects are nested, and thus multiple elements (points, lines, polygons) can share the same attributes. The <em>multi</em>-type of geometries allow to handle this kind of data in the same way as we would handle single points, lines or polygons.</p>
</div>
<div id="section-plotting-geometry-and-data-1" class="section level3">
<h3>Plotting geometry and data</h3>
<p>We have seen before that we can query both the geometry and the non spatial data of <code>sf</code> objects.</p>
<p>Let’s plot the geometry without any attributes:</p>
<div class="tutorial-exercise" data-label="polysex2" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia %>% st_geometry() %>% plot</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>Or plot ALL attributes. (This can be kind of annoying for very large and complex objects…)</p>
<div class="tutorial-exercise" data-label="polysex3" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia %>% plot</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section-5" class="section level3">
<h3></h3>
Usually we want to plot one single attribute, for example let’s choose the district variable, do you remember how to do this?:
<div class="tutorial-exercise" data-label="polysex4" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code># franconia %>% ____(district) %>% ____</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":true,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<div class="tutorial-exercise-support" data-label="polysex4-solution" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia %>% select(district) %>% plot</code></pre>
</div>
</div>
<div id="section-section-6" class="section level3">
<h3></h3>
<p>We can go one step further and dissolve the boundaries of adjacent municipalities of the same district, this will give us a new spatial object with three features:</p>
<div class="tutorial-exercise" data-label="polysex6" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia %>% group_by(district) %>% summarise(new_geom=st_union(geometry)) %>% plot</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>Notice how we can use spatial functions like <code>st_union</code> with other functions like <code>group_by</code> and <code>summarise</code>.</p>
</div>
<div id="section-spatial-query-of-a-polygon" class="section level3">
<h3>Spatial query of a polygon</h3>
<p>If all our data is in the same projection (sharing the same or similar <em>crs</em>) we can perform spatial queries, for example, we want to extract the intersection of the location of the University of Bayreuth (in object UBT) with the Franconia municipalities (in object franconia)</p>
<div class="tutorial-exercise" data-label="polysex7" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>st_intersection(UBT,franconia)</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>The result is a point geometry with all variables from the UBT and the franconia data sets.</p>
<div class="panel panel-default">
<div data-label="where_is_UBT" class="tutorial-question panel-body">
<div id="where_is_UBT-answer_container" class="shiny-html-output"></div>
<div id="where_is_UBT-message_container" class="shiny-html-output"></div>
<div id="where_is_UBT-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
</div>
<div id="section-plotting-spatial-data" class="section level3">
<h3>Plotting spatial data</h3>
<p>Simple feature object have their own plot functions, but I find it easier to combine different spatial objects with the <code>ggplot2</code> functions.</p>
<p>In <code>ggplot</code>, each layer of plot elements is handled by a <code>geom_</code> function, for <code>sf</code> object the function is called <code>geom_sf</code>.</p>
<p>We can combine the geom_sf calls with other ggplot functions to modify colors, etc.</p>
<pre class="r"><code>ggplot() +
geom_sf(data = franconia, aes(fill=district)) +
geom_sf(data = breweries, col="darkgreen") +
geom_sf(data = UBT, cex=2, col="brown") +
scale_fill_brewer(palette = "Greys")</code></pre>
<p><img src="tutorial-2-points-lines-polygons_files/figure-html/unnamed-chunk-12-1.png" width="624" /></p>
</div>
<div id="section-section-7" class="section level3">
<h3></h3>
<p>Better yet, in <code>ggplot</code> we can use variables in different aesthetic elements of the plot, for example, colour or size:</p>
<pre class="r"><code>ggplot() +
geom_sf(data = franconia, aes(fill=district)) +
geom_sf(data = breweries, aes(size=number.of.types, colour=founded)) +
geom_sf(data = UBT, cex=2, col="brown") +
scale_fill_brewer(palette = "Greys") +
scale_colour_gradientn(colours = brewer.pal(5,"Oranges"))</code></pre>
<pre><code>## Warning: Removed 150 rows containing missing values (geom_sf).</code></pre>
<p><img src="tutorial-2-points-lines-polygons_files/figure-html/unnamed-chunk-13-1.png" width="624" /></p>
</div>
<div id="section-section-8" class="section level3">
<h3></h3>
<p>We just learned to work with polygons, how to use spatial functions <code>st_union</code>, <code>st_intersection</code> and how to plot spatial objects with <code>ggplot</code>, well done!</p>
<p>In the next section we will work with objects in different projections.</p>
</div>
</div>
<div id="section-explore-lines-with-sf" class="section level2">
<h2>Explore lines with <code>sf</code></h2>
<div id="section-hiking-in-franconia" class="section level3">
<h3>Hiking in Franconia</h3>
<p>This data set has a selection of hiking trails in Franconia, the geometry here is a <em>multistring</em>, which are collections of lines. Notice that in this case we are using a different EPSG code, it refers to a specific zone of the Universal Transverse Mercator projection for this region of the world.</p>
<div class="tutorial-exercise" data-label="linesex1" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>trails</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>Again, if you see a warning about old-style <em>crs</em>, then reassign the same <em>crs</em>.</p>
<pre class="r"><code>st_crs(trails) <- "EPSG:32632"</code></pre>
<table>
<tbody>
<tr class="odd">
<td>The <a href="https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system">Universal Transverse Mercator (UTM)</a> is a map projection system for assigning coordinates to locations on the surface of the Earth. The UTM system divides the Earth into 60 zones, each 6° of longitude in width, and uses a projection that can map a region of large north-south extent with low distortion.</td>
</tr>
</tbody>
</table>
</div>
<div id="section-length-and-area-of-spatial-objects" class="section level3">
<h3>Length and area of spatial objects</h3>
<p>We are often interested in the spatial dimensions of object, for example in this case we want to know the length of each trail, we use the function <code>st_length</code>:</p>
<div class="tutorial-exercise" data-label="linesex2" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>trails %>% st_length() %>% hist(main="Length of trails")</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section-9" class="section level3">
<h3></h3>
<p>Often you want to add information to your spatial object, so that you can use that information latter in your map or in other analysis, here we will use the function <code>mutate</code> to add the length as a variable of the trails object, and then find the longest trail for a hiking excursion.</p>
<div class="tutorial-exercise" data-label="linesex3" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>trails %>% mutate(length=st_length(geometry)) -> trails
trails %>% slice(which.max(length))</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section-10" class="section level3">
<h3></h3>
<p>We can also filter by a desired length and create objects for short and long trails:</p>
<pre class="r"><code>trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(3000,'m'),length<set_units(3400,'m')) -> short_trails
trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails</code></pre>
</div>
<div id="section-projections-and-plots-maps" class="section level3">
<h3>Projections and plots (maps)</h3>
<p>When plotting object, <code>geom_sf</code> will handle the projections automatically, in this case the trails object is projected to geographical coordinates (some people would call this “inverse projection”). Notice the <a href="https://www.thefreedictionary.com/graticule">graticule</a> of geographical coordinates in the background is rectilinear (straight lines in the background)?</p>
<pre class="r"><code>ggplot() +
geom_sf(data = franconia, aes(fill=district)) +
geom_sf(data = UBT, cex=2, col="yellow") +
geom_sf(data = long_trails, col="whitesmoke")</code></pre>
<p><img src="tutorial-2-points-lines-polygons_files/figure-html/unnamed-chunk-16-1.png" width="624" /></p>
</div>
<div id="section-section-11" class="section level3">
<h3></h3>
<p>If we want to have all our data in the UTM projection, we could invert the order in which we call the objects:</p>
<div class="tutorial-exercise" data-label="linesex4" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>ggplot() +
geom_sf(data=long_trails, col="whitesmoke") +
geom_sf(data = franconia , aes(fill=district)) +
geom_sf(data=UBT , cex=2, col="yellow")</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>How does this look? Do you notice the graticule behind our object has changed?</p>
<p>Unfortunately the lines are overlaid with polygons and we can not see them. So this is NOT the best way to do this.</p>
</div>
<div id="section-section-12" class="section level3">
<h3></h3>
<p>If we want to have all our data projected on the fly, we can add a call to <code>coord_sf</code> and specify our choice of <em>crs</em>:</p>
<div class="tutorial-exercise" data-label="linesex5" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>ggplot() +
geom_sf(data = franconia, aes(fill=district)) +
geom_sf(data = UBT, cex=2, col="yellow") +
geom_sf(data = long_trails, col="whitesmoke") +
coord_sf(crs=st_crs(long_trails))</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-section-13" class="section level3">
<h3></h3>
<p>However, if we want to work with the projected data more than once, we can save time by doing the transformation once and then using the projected objects instead of the originals.</p>
<p>Let’s try a projection, just hit the run button to see what this means:</p>
<div class="tutorial-exercise" data-label="projectionex1" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>(UBT_utm = UBT %>% st_transform(st_crs(trails)))</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":true,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>Can you do the same with the franconia dataset?</p>
<div class="tutorial-exercise" data-label="projectionex2" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code># franconia_utm = ____ %>% ____(____)</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":true,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<div class="tutorial-exercise-support" data-label="projectionex2-solution" data-completion="1" data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code>franconia_utm = franconia %>% st_transform(st_crs(trails))</code></pre>
</div>
</div>
<div id="section-section-14" class="section level3">
<h3></h3>
<p>Check how this look like</p>
<pre class="r"><code>ggplot() +
geom_sf(data = franconia_utm, aes(fill=district)) +
geom_sf(data = UBT_utm, cex=2, col="yellow") +
geom_sf(data =long_trails, col="whitesmoke")</code></pre>
<p><img src="tutorial-2-points-lines-polygons_files/figure-html/unnamed-chunk-17-1.png" width="624" /></p>
</div>
<div id="section-thats-it-from-me" class="section level3">
<h3>That’s it from me!</h3>
<p>In this last section we learned to work with lines, how to use spatial functions <code>st_length</code> and how to handle projections of spatial objects with ggplot<code>and with the function</code>st_transform`. Great!</p>
<p>I hope this has been useful and you feel more confident to start working with geo-spatial data in R.</p>
Check the next tutorials in our <a href="https://github.com/UNSW-codeRs/geospatial-data-in-R">geospatial-data repository</a>
<script type="application/shiny-prerendered" data-context="server-start">
library(learnr)
library(tidyverse)
library(sf)
library(mapview)
library(units)
require(RColorBrewer)
tutorial_options(
exercise.timelimit = 60,
# A simple checker function that just returns the message in the check chunk
exercise.checker = function(check_code, ...) {
list(
message = eval(parse(text = check_code)),
correct = logical(0),
type = "info",
location = "append"
)
}
)
knitr::opts_chunk$set(error = TRUE)
UBT <- st_sf(data.frame(full_name='Universität Bayreuth',
url='https://uni-bayreuth.de/'),
crs=st_crs("EPSG:4326"),
geometry=st_sfc(
st_point(c(11.585833, 49.928889))))
st_crs(franconia) <- "EPSG:4326"
st_crs(breweries) <- "EPSG:4326"
st_crs(trails) <- "EPSG:32632"
franconia_utm = franconia %>% st_transform(st_crs(trails))
UBT_utm = UBT %>% st_transform(st_crs(trails))
trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::register_http_handlers(session, metadata = NULL)
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::prepare_tutorial_state(session)
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::i18n_observe_tutorial_language(input, session)
</script>
<script type="application/shiny-prerendered" data-context="server">
session$onSessionEnded(function() {
learnr:::event_trigger(session, "session_stop")
})
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex1-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex1-code-editor`)), session)
output$`tutorial-exercise-pointsex1-output` <- renderUI({
`tutorial-exercise-pointsex1-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex1", code = "breweries",
opts = list(label = "\"pointsex1\"", exercise = "TRUE",
paged.print = "FALSE"), engine = "r")), code_check = NULL,
error_check = NULL, check = NULL, solution = NULL, test_cases = NULL,
options = list(eval = FALSE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex1", exercise = TRUE, paged.print = FALSE,
code = "breweries", out.width.px = 624, out.height.px = 384,
params.src = "pointsex1, exercise=TRUE, paged.print=FALSE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex2-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex2-code-editor`)), session)
output$`tutorial-exercise-pointsex2-output` <- renderUI({
`tutorial-exercise-pointsex2-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex2", code = "breweries %>% st_drop_geometry()",
opts = list(label = "\"pointsex2\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex2", exercise = TRUE, code = "breweries %>% st_drop_geometry()",
out.width.px = 624, out.height.px = 384, params.src = "pointsex2, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex3-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex3-code-editor`)), session)
output$`tutorial-exercise-pointsex3-output` <- renderUI({
`tutorial-exercise-pointsex3-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex3", code = "breweries %>% st_geometry()",
opts = list(label = "\"pointsex3\"", exercise = "TRUE",
paged.print = "FALSE"), engine = "r")), code_check = NULL,
error_check = NULL, check = NULL, solution = NULL, test_cases = NULL,
options = list(eval = FALSE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex3", exercise = TRUE, paged.print = FALSE,
code = "breweries %>% st_geometry()", out.width.px = 624,
out.height.px = 384, params.src = "pointsex3, exercise=TRUE, paged.print=FALSE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex4-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex4-code-editor`)), session)
output$`tutorial-exercise-pointsex4-output` <- renderUI({
`tutorial-exercise-pointsex4-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex4", code = "breweries %>% pull(number.of.types) %>% hist(main=\"Nr. of types of beers\")",
opts = list(label = "\"pointsex4\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex4", exercise = TRUE, code = "breweries %>% pull(number.of.types) %>% hist(main=\"Nr. of types of beers\")",
out.width.px = 624, out.height.px = 384, params.src = "pointsex4, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex5-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex5-code-editor`)), session)
output$`tutorial-exercise-pointsex5-output` <- renderUI({
`tutorial-exercise-pointsex5-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex5", code = "breweries %>% select(number.of.types) %>% plot(pch=19)",
opts = list(label = "\"pointsex5\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex5", exercise = TRUE, code = "breweries %>% select(number.of.types) %>% plot(pch=19)",
out.width.px = 624, out.height.px = 384, params.src = "pointsex5, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-pointsex6-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-pointsex6-code-editor`)), session)
output$`tutorial-exercise-pointsex6-output` <- renderUI({
`tutorial-exercise-pointsex6-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "pointsex6", code = "selected_breweries <- breweries %>% filter(number.of.types>9)\nqry <- st_nearest_feature(UBT,selected_breweries)\nselected_breweries %>% slice(qry)\nst_distance(UBT,selected_breweries %>% slice(qry))",
opts = list(label = "\"pointsex6\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "pointsex6", exercise = TRUE, code = c("selected_breweries <- breweries %>% filter(number.of.types>9)",
"qry <- st_nearest_feature(UBT,selected_breweries)",
"selected_breweries %>% slice(qry)", "st_distance(UBT,selected_breweries %>% slice(qry))"
), out.width.px = 624, out.height.px = 384, params.src = "pointsex6, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::question_prerendered_chunk(structure(list(type = "learnr_radio", label = "how_many_beers",
question = structure("What's the name of the place, How many types of beers will we find there? and how far do we have to travel? ", html = TRUE, class = c("html",
"character")), answers = list(structure(list(id = "lnr_ans_f4b209f",
option = "Brauerei Huetten, 10 km and 14808 beers", value = "Brauerei Huetten, 10 km and 14808 beers",
label = structure("Brauerei Huetten, 10 km and 14808 beers", html = TRUE, class = c("html",
"character")), correct = FALSE, message = structure("Ok, you have had too many beers, please try again", html = TRUE, class = c("html",
"character")), type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_1e274c0",
option = "Kitzmann-Braeu, 14 beers and 55 km", value = "Kitzmann-Braeu, 14 beers and 55 km",
label = structure("Kitzmann-Braeu, 14 beers and 55 km", html = TRUE, class = c("html",
"character")), correct = FALSE, message = structure("Did you change the threshold? this is a far ride, but gets you the largest variety of beers", html = TRUE, class = c("html",
"character")), type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_3612033",
option = "Brauerei Huetten, 10 beers and 14.8 km", value = "Brauerei Huetten, 10 beers and 14.8 km",
label = structure("Brauerei Huetten, 10 beers and 14.8 km", html = TRUE, class = c("html",
"character")), correct = TRUE, message = NULL, type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_4410769",
option = "Brauhaus Leikeim, 11 beers, 33km ", value = "Brauhaus Leikeim, 11 beers, 33km ",
label = structure("Brauhaus Leikeim, 11 beers, 33km ", html = TRUE, class = c("html",
"character")), correct = FALSE, message = structure("Did you change the threshold? A good choice if you really need more than ten beers.", html = TRUE, class = c("html",
"character")), type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer"))), button_labels = list(submit = structure("<span data-i18n=\"button.questionsubmit\">Submit Answer<\u002fspan>", html = TRUE, class = c("html",
"character")), try_again = structure("<span data-i18n=\"button.questiontryagain\">Try Again<\u002fspan>", html = TRUE, class = c("html",
"character"))), messages = list(correct = structure("Correct!", html = TRUE, class = c("html",
"character")), try_again = structure("Incorrect", html = TRUE, class = c("html",
"character")), incorrect = structure("Incorrect", html = TRUE, class = c("html",
"character")), message = NULL, post_message = NULL), ids = list(
answer = "how_many_beers-answer", question = "how_many_beers"),
loading = structure("<strong>Loading:<\u002fstrong> \n What's the name of the place, How many types of beers will we find there? and how far do we have to travel? \n<br/><br/><br/>", html = TRUE, class = c("html",
"character")), random_answer_order = FALSE, allow_retry = TRUE,
seed = 1185913159.94777, options = list()), class = c("learnr_radio",
"tutorial_question")), session = session)
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-polysex1-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-polysex1-code-editor`)), session)
output$`tutorial-exercise-polysex1-output` <- renderUI({
`tutorial-exercise-polysex1-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "polysex1", code = "franconia",
opts = list(label = "\"polysex1\"", exercise = "TRUE",
paged.print = "FALSE"), engine = "r")), code_check = NULL,
error_check = NULL, check = NULL, solution = NULL, test_cases = NULL,
options = list(eval = FALSE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "polysex1", exercise = TRUE, paged.print = FALSE,
code = "franconia", out.width.px = 624, out.height.px = 384,
params.src = "polysex1, exercise=TRUE, paged.print=FALSE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-polysex2-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-polysex2-code-editor`)), session)
output$`tutorial-exercise-polysex2-output` <- renderUI({
`tutorial-exercise-polysex2-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "polysex2", code = "franconia %>% st_geometry() %>% plot",
opts = list(label = "\"polysex2\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "polysex2", exercise = TRUE, code = "franconia %>% st_geometry() %>% plot",
out.width.px = 624, out.height.px = 384, params.src = "polysex2, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-polysex3-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-polysex3-code-editor`)), session)
output$`tutorial-exercise-polysex3-output` <- renderUI({
`tutorial-exercise-polysex3-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "polysex3", code = "franconia %>% plot",
opts = list(label = "\"polysex3\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = NULL, solution = NULL, test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = TRUE,
message = TRUE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, exercise.timelimit = 60, exercise.checker = "function (check_code, ...) \n{\n list(message = eval(parse(text = check_code)), correct = logical(0), \n type = \"info\", location = \"append\")\n}",
label = "polysex3", exercise = TRUE, code = "franconia %>% plot",
out.width.px = 624, out.height.px = 384, params.src = "polysex3, exercise=TRUE",
fig.num = 0, exercise.df_print = "paged"), engine = "r"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-polysex4-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-polysex4-code-editor`)), session)
output$`tutorial-exercise-polysex4-output` <- renderUI({
`tutorial-exercise-polysex4-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(global_setup = structure(c("library(learnr)",
"library(tidyverse)", "library(sf)", "library(mapview)", "library(units)",
"require(RColorBrewer)", "", "tutorial_options(", " exercise.timelimit = 60,",
" # A simple checker function that just returns the message in the check chunk",
" exercise.checker = function(check_code, ...) {", " list(",
" message = eval(parse(text = check_code)),", " correct = logical(0),",
" type = \"info\",", " location = \"append\"", " )",
" }", ")", "knitr::opts_chunk$set(error = TRUE)", "", "UBT <- st_sf(data.frame(full_name='Universität Bayreuth',",
" url='https://uni-bayreuth.de/'),", " crs=st_crs(\"EPSG:4326\"),",
" geometry=st_sfc(", " st_point(c(11.585833, 49.928889))))",
"", "st_crs(franconia) <- \"EPSG:4326\"", "st_crs(breweries) <- \"EPSG:4326\"",
"st_crs(trails) <- \"EPSG:32632\"", "", "franconia_utm = franconia %>% st_transform(st_crs(trails))",
"UBT_utm = UBT %>% st_transform(st_crs(trails))", "", "trails %>% mutate(length=st_length(geometry)) %>% filter(length>set_units(40000,'m')) -> long_trails",
""), chunk_opts = list(label = "setup", include = FALSE)), setup = NULL,
chunks = list(list(label = "polysex4", code = "# franconia %>% ____(district) %>% ____",
opts = list(label = "\"polysex4\"", exercise = "TRUE"),
engine = "r")), code_check = NULL, error_check = NULL,
check = structure("\"Great! we first use `select` to select the variable and then `plot` to call the default plot function for `sf` objects\"", chunk_opts = list(
label = "polysex4-check")), solution = structure("franconia %>% select(district) %>% plot", chunk_opts = list(
label = "polysex4-solution")), test_cases = NULL, options = list(
eval = FALSE, echo = TRUE, results = "markup", tidy = FALSE,
tidy.opts = NULL, collapse = FALSE, prompt = FALSE, comment = NA,
highlight = FALSE, size = "normalsize", background = "#F7F7F7",
strip.white = TRUE, cache = 0, cache.path = "tutorial-2-points-lines-polygons_cache/html/",
cache.vars = NULL, cache.lazy = TRUE, dependson = NULL,
autodep = FALSE, cache.rebuild = FALSE, fig.keep = "high",
fig.show = "asis", fig.align = "default", fig.path = "tutorial-2-points-lines-polygons_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,