-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_GEOG364-22_L7Point.html
1087 lines (1038 loc) · 59.2 KB
/
index_GEOG364-22_L7Point.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
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="Dr Greatrex" />
<meta name="date" content="2022-12-12" />
<title> Lab 7 point pattern</title>
<script src="site_libs/header-attrs-2.17/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.7/js/bootstrap.min.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/robobook-0.1/robobook.css" rel="stylesheet" />
<link href="site_libs/robobook-0.1/robobook_fonts_embed.css" rel="stylesheet" />
<script src="site_libs/robobook-0.1/robobook.js"></script>
<script src="site_libs/kePrint-0.0.1/kePrint.js"></script>
<link href="site_libs/lightable-0.0.1/lightable.css" rel="stylesheet" />
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
background-color: #ffffff;
color: #a0a0a0;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #a0a0a0; padding-left: 4px; }
div.sourceCode
{ color: #1f1c1b; background-color: #ffffff; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { color: #1f1c1b; } /* Normal */
code span.al { color: #bf0303; background-color: #f7e6e6; font-weight: bold; } /* Alert */
code span.an { color: #ca60ca; } /* Annotation */
code span.at { color: #0057ae; } /* Attribute */
code span.bn { color: #b08000; } /* BaseN */
code span.bu { color: #644a9b; font-weight: bold; } /* BuiltIn */
code span.cf { color: #1f1c1b; font-weight: bold; } /* ControlFlow */
code span.ch { color: #924c9d; } /* Char */
code span.cn { color: #aa5500; } /* Constant */
code span.co { color: #898887; } /* Comment */
code span.cv { color: #0095ff; } /* CommentVar */
code span.do { color: #607880; } /* Documentation */
code span.dt { color: #0057ae; } /* DataType */
code span.dv { color: #b08000; } /* DecVal */
code span.er { color: #bf0303; text-decoration: underline; } /* Error */
code span.ex { color: #0095ff; font-weight: bold; } /* Extension */
code span.fl { color: #b08000; } /* Float */
code span.fu { color: #644a9b; } /* Function */
code span.im { color: #ff5500; } /* Import */
code span.in { color: #b08000; } /* Information */
code span.kw { color: #1f1c1b; font-weight: bold; } /* Keyword */
code span.op { color: #1f1c1b; } /* Operator */
code span.ot { color: #006e28; } /* Other */
code span.pp { color: #006e28; } /* Preprocessor */
code span.re { color: #0057ae; background-color: #e0e9f8; } /* RegionMarker */
code span.sc { color: #3daee9; } /* SpecialChar */
code span.ss { color: #ff5500; } /* SpecialString */
code span.st { color: #bf0303; } /* String */
code span.va { color: #0057ae; } /* Variable */
code span.vs { color: #bf0303; } /* VerbatimString */
code span.wa { color: #bf0303; } /* Warning */
</style>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("toc");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open')
});
});
</script>
<!-- code folding -->
<!-- code download -->
<!-- tabsets dropdown -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
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.active a {
padding: 0 15px !important;
}
.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;
margin-left: 0 !important;
}
</style>
</head>
<body class="preload">
<!-- robobook start -->
<div class="book with-summary">
<div class="book-summary">
<ul>
<li class="title"><br> Lab 7 point pattern</li>
<li class="divider"></li>
</ul>
<nav role="navigation" id="toc">
<ul>
<li><a href="#welcome-to-lab-7"
id="toc-welcome-to-lab-7">Welcome to Lab 7!</a></li>
<li><a href="#get-help" id="toc-get-help">Get help</a></li>
<li><a href="#lab-set-up---read-this-you-will-be-graded"
id="toc-lab-set-up---read-this-you-will-be-graded"><span
class="toc-section-number">1</span> LAB SET-UP - READ THIS,
YOU WILL BE GRADED!</a>
<ul>
<li><a href="#create-project" id="toc-create-project"><span
class="toc-section-number">1.1</span> Create project</a></li>
<li><a href="#select-template."
id="toc-select-template."><span
class="toc-section-number">1.2</span> Select
template.</a></li>
<li><a href="#add-libraries" id="toc-add-libraries"><span
class="toc-section-number">1.3</span> Add libraries</a></li>
<li><a href="#add-a-screenshot"
id="toc-add-a-screenshot"><span
class="toc-section-number">1.4</span> Add a
screenshot</a></li>
<li><a href="#explain-your-choices"
id="toc-explain-your-choices"><span
class="toc-section-number">1.5</span> Explain your
choices</a></li>
</ul></li>
<li><a href="#fossil-data-analysis"
id="toc-fossil-data-analysis"><span
class="toc-section-number">2</span> FOSSIL DATA ANALYSIS</a>
<ul>
<li><a href="#data-description"
id="toc-data-description"><span
class="toc-section-number">2.1</span> Data
Description</a></li>
<li><a href="#make-spatial-plot"
id="toc-make-spatial-plot"><span
class="toc-section-number">2.2</span> Make Spatial,
Plot</a></li>
<li><a href="#make-ppp-version"
id="toc-make-ppp-version"><span
class="toc-section-number">2.3</span> Make ppp
version</a></li>
<li><a href="#centography" id="toc-centography"><span
class="toc-section-number">2.4</span> Centography</a></li>
<li><a href="#point-pattern-auto-correlation"
id="toc-point-pattern-auto-correlation"><span
class="toc-section-number">2.5</span> Point Pattern
auto-correlation</a></li>
</ul></li>
<li><a href="#above-beyond" id="toc-above-beyond"><span
class="toc-section-number">3</span> ABOVE &
BEYOND</a></li>
<li><a href="#predict-your-grade"
id="toc-predict-your-grade"><span
class="toc-section-number">4</span> Predict your grade</a>
<ul>
<li><a href="#what-your-grade-means"
id="toc-what-your-grade-means"><span
class="toc-section-number">4.1</span> What your grade
means</a></li>
</ul></li>
</ul>
</nav>
<ul class="authors">
<li class="divider"></li>
<li><span><i class="glyphicon glyphicon-user"></i> Dr
Greatrex</span></li>
<li><span><i class="glyphicon glyphicon-calendar"></i> 2022-12-12</span></li>
</ul>
</div>
<div class="book-body fixed">
<div class="body-inner">
<a class="btn pull-left js-toolbar-action toggle-sidebar" aria-label="Toggle Sidebar" title="Toggle Sidebar" href="#">
<span class="glyphicon glyphicon-menu-hamburger"></span>
</a>
<div class="page-inner">
<section id="content" class="normal">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">GEOG-364</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="index_GEOG364-22_Tutorial_R.html">R-TUTORIAL</a>
</li>
<li>
<a href="ClassExampleMoran.html">CLASS EXAMPLE MORAN'S I LAB 6</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Labs
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="index_GEOG364-22_L1Basics.html">Lab 1: R-Basics</a>
</li>
<li>
<a href="index_GEOG364-22_L2EDA.html">Lab 2: Exploratory Analysis</a>
</li>
<li>
<a href="index_GEOG364-22_L3Data.html">Lab 3: Data Wrangling</a>
</li>
<li>
<a href="index_GEOG364-22_L4Firefly.html">Lab 4: Spatial Wrangling</a>
</li>
<li>
<a href="index_GEOG364-22_L5Census.html">Lab 5: Census Data</a>
</li>
<li>
<a href="index_GEOG364-22_L6SoviMoran.html">Lab 6: Moran SOVI</a>
</li>
<li>
<a href="index_GEOG364-22_L7Point.html">Lab 7: Point Pattern</a>
</li>
<li>
<a href="index_GEOG364-22_Temp.html">TEMPERATURE LAB</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<h1 class="title"><br> Lab 7 point pattern</h1>
<!-- Don't indent these lines or it will mess pre blocks indentation -->
<div id="welcome-to-lab-7" class="section level2 unnumbered">
<h2 class="unnumbered">Welcome to Lab 7!</h2>
<p><br></p>
<p>Welcome to your final lab, where we are going to focus on Point
Pattern Analysis, a specific set of spatial statistics tools we are can
use for point datasets. A point dataset can be anything with a specific
location, from stars, to greenhouses.</p>
<p>You will also be showing me that you can do each element of report
writing process.</p>
<p>We will be focusing on:</p>
<ul>
<li>Descriptive statistics</li>
<li>Density based spatial statistics (Kernel smoothing, quadrat
analysis)</li>
<li>Distance based spatial statistics ( nearest neighbour analysis and
the F, G, K and L functions.)</li>
<li>We will also work on downloading raster elevation and population
density data</li>
</ul>
<p>SEE CANVAS FOR SUBMISSION DATES.</p>
</div>
<div id="get-help" class="section level2 unnumbered">
<h2 class="unnumbered">Get help</h2>
<p>If a link to a tutorial is broken, you should be able to go to the
tutorial number and find it in the menu.</p>
<p>Teams is the fastest way to get help. <a
href="https://teams.microsoft.com/l/team/19%3aSt_BHDOZLAgR9dsxgB2ly3-O77CnxyzoGFVYc0fpUTM1%40thread.tacv2/conversations?groupId=5e74a2d7-3a10-409a-b38d-50875fd02455&tenantId=7cf48d45-3ddb-4389-a9c1-c115526eb52e">CLICK
THIS LINK FOR THE TEAMS WEBSITE FOR LAB HELP</a></p>
<p><br></p>
</div>
<div id="lab-set-up---read-this-you-will-be-graded"
class="section level1" number="1">
<h1><span class="header-section-number">1</span> LAB SET-UP - READ THIS,
YOU WILL BE GRADED!</h1>
<p><br></p>
<div id="create-project" class="section level2" number="1.1">
<h2><span class="header-section-number">1.1</span> Create project</h2>
<ul>
<li>Using R-CLOUD? : click here. This also has instructions on
uploading/downloading code from your computers. <a
href="https://psu-spatial.github.io/Geog364-2022/index_GEOG364-22_Tutorial_R.html#2_R-Studio_CLOUD"
class="uri">https://psu-spatial.github.io/Geog364-2022/index_GEOG364-22_Tutorial_R.html#2_R-Studio_CLOUD</a>
<br><br></li>
<li>Using YOUR LAPTOP? : Click here: - <a
href="https://psu-spatial.github.io/Geog364-2022/index_GEOG364-22_Tutorial_R.html#3_R-Studio_Desktop"
class="uri">https://psu-spatial.github.io/Geog364-2022/index_GEOG364-22_Tutorial_R.html#3_R-Studio_Desktop</a></li>
</ul>
<p><br></p>
</div>
<div id="select-template." class="section level2" number="1.2">
<h2><span class="header-section-number">1.2</span> Select template.</h2>
<p>Create your markdown file and choose a professional template, such as
<code>PACKAGE rmdformats</code>, <code>PACKAGE rtemps</code> or
<code>PACKAGE prettydoc</code>. You simply need to install the package
from the “app store”, then go to new Markdown FROM TEMPLATE. See the
start of Lab 5 for a reminder. To browse the formats, see here:</p>
<ul>
<li>rmdformats : <a href="https://github.com/juba/rmdformats"
class="uri">https://github.com/juba/rmdformats</a></li>
<li>pretty docs : <a href="https://prettydoc.statr.me/themes.html"
class="uri">https://prettydoc.statr.me/themes.html</a></li>
<li>rtemps : <a href="https://github.com/bblodfon/rtemps"
class="uri">https://github.com/bblodfon/rtemps</a></li>
</ul>
<p>If you want to make websites or other formats, see here: <a
href="https://r4ds.had.co.nz/r-markdown-formats.html"
class="uri">https://r4ds.had.co.nz/r-markdown-formats.html</a>, here: <a
href="https://bookdown.org/yihui/rmarkdown/tufte-handouts.html"
class="uri">https://bookdown.org/yihui/rmarkdown/tufte-handouts.html</a>
or here <a href="https://rmarkdown.rstudio.com/formats.html"
class="uri">https://rmarkdown.rstudio.com/formats.html</a>.</p>
<p><br></p>
</div>
<div id="add-libraries" class="section level2" number="1.3">
<h2><span class="header-section-number">1.3</span> Add libraries</h2>
<p><strong>Edit the first “set-up” code chunk so it looks like this and
run/knit. You might need additional libraries as you work through the
lab. If so, add them in this code chunk AND REMEMBER TO RE-RUN THE CODE
CHUNK.</strong></p>
<p>If you see a little yellow bar at the top asking you to install
them,click yes! If you find a library doesn’t exist, install it from the
app store, then add the library command in here to load.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># SET UP</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>knitr<span class="sc">::</span>opts_chunk<span class="sc">$</span><span class="fu">set</span>(<span class="at">cache =</span> <span class="cn">TRUE</span>,<span class="at">message=</span><span class="cn">FALSE</span>,<span class="at">warning=</span><span class="cn">FALSE</span>,<span class="at">echo=</span><span class="cn">TRUE</span>)</span></code></pre></div>
<p>NOTE, I HAVE SPLIT THESE CODE CHUNKS IN TWO FOR THE TOP COMMAND TO
PRINT.</p>
<p><strong>PLEASE ALSO SPLIT THEM</strong></p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># LIBRARIES</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr)</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggpubr)</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(skimr)</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(plotly)</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(knitr)</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(raster)</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sp)</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf)</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tmap)</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(terra)</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(rnaturalearth)</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(biscale)</span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidycensus)</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(cowplot)</span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(units)</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(remotes)</span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(elevatr)</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(RColorBrewer)</span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(spatstat)</span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(car)</span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(maptools)</span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(USAboundaries)</span></code></pre></div>
<p>Note, if you don’t have elevatr, you will need to first install the
<code>remotes</code> package, then run this code IN THE CONSOLE to get
the package.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>remotes<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">"jhollist/elevatr"</span>)</span></code></pre></div>
<p>If car or maptools don’t work, don’t panic, just remove from the code
chunk.</p>
<p><br></p>
</div>
<div id="add-a-screenshot" class="section level2" number="1.4">
<h2><span class="header-section-number">1.4</span> Add a screenshot</h2>
<ul>
<li>Take a screenshot of your entire screen showing that you are running
your project and have created your template. Add this screenshot into
your report</li>
</ul>
<p>Hint: To add a picture, see your old labs or <a
href="https://psu-spatial.github.io/Geog364-2022/index_GEOG364-22_Tutorial_R.html#96_Adding_photos">Tutorial
9.6</a>.</p>
<p><br></p>
</div>
<div id="explain-your-choices" class="section level2" number="1.5">
<h2><span class="header-section-number">1.5</span> Explain your
choices</h2>
<ul>
<li><p>Under the screenshot, state which markdown template you used and
provide a link to the package’s github or CRAN website (bonus if your
link is a web-hyperlink <a href="https://xkcd.com/2696/">that you can
click like this</a>)</p></li>
<li><p>Then use the citation command in the console to get the citation
for your package and include the citation in this section of your
report. <br><br> For example to cite the skimr package I would type
<code>citation("skimr")</code> then copy this link into my report.</p>
<ul>
<li>Waring E, Quinn M, McNamara A, Arino de la Rubia E, Zhu H, Ellis S
(2022). <em>skimr: Compact and Flexible Summaries of Data</em>. R
package version 2.1.4, <a
href="https://CRAN.R-project.org/package=skimr"
class="uri">https://CRAN.R-project.org/package=skimr</a>.</li>
</ul></li>
</ul>
<p><br></p>
</div>
</div>
<div id="fossil-data-analysis" class="section level1" number="2">
<h1><span class="header-section-number">2</span> FOSSIL DATA
ANALYSIS</h1>
<p>I have given you much of the code here.</p>
<div id="data-description" class="section level2" number="2.1">
<h2><span class="header-section-number">2.1</span> Data Description</h2>
<ol style="list-style-type: decimal">
<li>Use this code to automatically download the data and read it into R.
Remember to retype ALL the quote marks if you get a weird error.
<br></li>
</ol>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">#Where the data is stored</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> url_data <span class="ot"><-</span> <span class="st">"https://raw.githubusercontent.com/hgreatrex/GEOG364_Labs/master/Lab_4/PA_fossils.csv"</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="co">#Download it into your project folder and read it into R</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">download.file</span>(url_data, <span class="at">destfile =</span> <span class="st">"PA_fossils.csv"</span> , <span class="at">verbose=</span><span class="cn">TRUE</span>)</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> fossil <span class="ot"><-</span> <span class="fu">read.csv</span>(<span class="st">"PA_fossils.csv"</span>)</span></code></pre></div>
<ol start="2" style="list-style-type: decimal">
<li><p>Take a look at the data (remember the <code>View()</code>
command). <br></p></li>
<li><p>Create a new code chunk and use the dim, names and summary
commands to work out how many rows and columns the data has. Use the
table command on the period column (or your own method) to see how many
fossils were found in the Mississippian time-period. <br></p></li>
<li><p>The data comes from this website: <a
href="https://paleobiodb.org/" class="uri">https://paleobiodb.org/</a>.
<br> Have a look around, especially about how the data was collected. We
are focusing particularly on Pennsylvania in our subset. <br></p></li>
<li><p>Now, <a
href="https://psu-spatial.github.io/Geog364-2022/ClassExampleMoran.html">USING
MY LAB 6 TEMPLATE AS AN EXAMPLE OF STYLE/CONTENT</a> and what you
learned from the data/the website, write a BRIEF background section
containing all relevant information about the dataset. Feel free to
copy/paste my example and change the details! Within this, explain if
the data is marked <br></p></li>
</ol>
</div>
<div id="make-spatial-plot" class="section level2" number="2.2">
<h2><span class="header-section-number">2.2</span> Make Spatial,
Plot</h2>
<p>Make a new sub-section.</p>
<ol start="6" style="list-style-type: decimal">
<li>Use this code to download the state borders. Note, some people said
Tigris is better for borders. Feel free to use that</li>
</ol>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co">#---------------------------------------------------------------------------------# us_states is from the USAboundaries package</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">#--------------------------------------------------------------------------------- </span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> state.border <span class="ot"><-</span> <span class="fu">us_states</span>(<span class="at">states =</span> <span class="st">"pennsylvania"</span>)</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> state.border.utm <span class="ot"><-</span> <span class="fu">st_transform</span>(state.border,<span class="dv">6346</span>)</span></code></pre></div>
<ol start="7" style="list-style-type: decimal">
<li>Use this code to download a raster of elevations for PA. Edit the
code chunk options so that it doesn’t output any text (<a
href="https://warin.ca/posts/rcourse-howto-usechunkoptions/#:~:text=The%20chunk%20option%20results%20%3D%20hide,of%20a%20spreadsheet%20in%20R">hint</a>).</li>
</ol>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co">#---------------------------------------------------------------------------------</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="co"># get_elev_raster is from the elevatr package. Might take a second to download</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="co">#---------------------------------------------------------------------------------</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> elevation.utm <span class="ot"><-</span> <span class="fu">get_elev_raster</span>(state.border.utm, <span class="at">z =</span> <span class="dv">5</span>,<span class="at">clip=</span><span class="st">"locations"</span>)</span></code></pre></div>
<ol start="8" style="list-style-type: decimal">
<li>Using the help files and tutorials as needed, edit these commands so
that your point is converted into sf format and the map projection is
changed to EPSG code 26918</li>
</ol>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------------------------------------------------</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Convert your fossil data to sf format adn change the map projection. Rename the variables to something</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="co"># sensible. crs=4326 is long/lat data. YOU WILL NEED TO EDIT THIS TO MAKE IT WORK</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------------------------------------------------</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> XXXX_sf <span class="ot"><-</span> <span class="fu">st_as_sf</span>( XXXX, <span class="at">coords =</span> <span class="fu">c</span>(<span class="st">"COLUMN_NAME X COORDS"</span>, <span class="st">"COLUMN_NAME Y COORDS"</span>), <span class="at">crs=</span><span class="dv">4326</span>)</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="co"># overwrite with new map projection</span></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> XXXX_sf <span class="ot"><-</span> <span class="fu">st_transform</span>(XXXX_sf,<span class="at">crs=</span><span class="dv">26918</span>)</span></code></pre></div>
<ol start="9" style="list-style-type: decimal">
<li>Using this link, <a href="https://epsg.io/26918-15839"
class="uri">https://epsg.io/26918-15839</a>, write below the code chunk
what map projection the data has been converted to and whether the units
are now in degrees or metres.</li>
</ol>
<p><strong>IMPORTANT HINT! As it stands, YOUR DATA WILL NOT PLOT. THINK
ABOUT WHAT YOU JUST DID WITH THE st_transform, then go back and check
your state border projection.. (once you figure it out, re-run from the
start</strong></p>
<ol start="10" style="list-style-type: decimal">
<li><p>Make a nice plot of the data showing me your skills from this
semester.</p></li>
<li><p>FOR THE SHOW ME SOMETHING NEW ADDITIONAL MARKS, make a nice map
of the ELEVATION DATA overlayed with unmarked fossils over the top, AND
state border - and making it look good.</p></li>
</ol>
</div>
<div id="make-ppp-version" class="section level2" number="2.3">
<h2><span class="header-section-number">2.3</span> Make ppp version</h2>
<p>We are now going to do a point pattern analysis, using a special
package called spatstat. This package requires that we convert the data
into a new data-format called ppp.</p>
<p>I have provided the code. By examining the as.ppp help file we see
that the ppp command requires 4 types of information: - x coordinates of
each event and y coordinates of each event (or a “sp” data format) -
window size (i.e., region size), - any marks (i.e., values/data for each
event).</p>
<p><strong>HINT! I THOUGHT ‘mydata’ was a stupid variable name. In my
code, it is fossil, fossil_sf etc. Either go back and change your
“mydata”, or going forwards, change the fossils to mydata. Or.. add in
<code>fossil_sf <- mydata_sf</code> and simply continue
;)</strong></p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># This just converts stateowin to a "window" file format</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> state.window <span class="ot"><-</span> <span class="fu">as</span>(<span class="fu">as_Spatial</span>(state.border.utm), <span class="st">"owin"</span>)</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># This turns the sf data into a ppp format, then sets the window</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> fossil_ppp <span class="ot"><-</span> <span class="fu">as.ppp</span>(fossil_sf)</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">Window</span>(fossil_ppp) <span class="ot"><-</span> state.window</span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="co">#and then we plot the data</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">plot</span>(elevation.utm)</span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">plot</span>(fossil_ppp,<span class="at">use.marks =</span> F,<span class="at">cex =</span> <span class="dv">1</span>, <span class="at">pch =</span> <span class="dv">4</span>,<span class="at">lwd=</span><span class="dv">1</span>,<span class="at">add=</span><span class="cn">TRUE</span>)</span></code></pre></div>
<ol start="12" style="list-style-type: decimal">
<li><p>Copy the code above into a new code chunk and make sure it runs.
You might get errors about Discarded datum Unknown based on GRS80
ellipsoid in CRS definition, or only first attribute column is used for
marks. Ignore them.</p></li>
<li><p>Look at the output of the plot, which shows the points plotted
over elevation data. Below the code chunk, write your assessment of the
spatial structure of the fossils. In your opinion do the locations show
positive or negative autocorrelation? What processess (if any) do you
think caused this pattern?</p></li>
</ol>
</div>
<div id="centography" class="section level2" number="2.4">
<h2><span class="header-section-number">2.4</span> Centography</h2>
<div id="standard-ellipse" class="section level3" number="2.4.1">
<h3><span class="header-section-number">2.4.1</span> Standard
ellipse</h3>
<p>This code plots the data, and adds the “mean centre” and “standard
ellipse”. Get it working in your report.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># Plot the elevation</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> mycolors <span class="ot"><-</span> <span class="fu">brewer.pal</span>(<span class="at">n=</span><span class="dv">11</span>, <span class="at">name =</span> <span class="st">"BrBG"</span>)[<span class="sc">-</span><span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">10</span>,<span class="dv">11</span>)]</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">plot</span>(elevation.utm,<span class="at">col=</span>mycolors)</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="co"># Add a "standard ellipse" from the car package</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># IF THIS DOESN'T WORK, don't include this code and just interpret my plot</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">dataEllipse</span>(fossil_ppp<span class="sc">$</span>x, fossil_ppp<span class="sc">$</span>y, <span class="at">levels=</span><span class="fl">0.68</span>, </span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="at">fill=</span><span class="cn">TRUE</span>, <span class="at">fill.alpha=</span><span class="fl">0.1</span>, <span class="co"># Fill the ellipse with transparent grey</span></span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="at">pch=</span><span class="dv">4</span>, <span class="at">cex=</span><span class="dv">1</span>, <span class="co"># little x's </span></span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="at">xlab=</span><span class="st">"x (m)"</span>,<span class="at">ylab=</span><span class="st">"y (m)"</span>, </span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="at">col=</span> <span class="fu">c</span>(<span class="fu">rgb</span>(<span class="at">red=</span><span class="dv">0</span>, <span class="at">green=</span><span class="dv">0</span>, <span class="at">blue=</span><span class="dv">0</span>, <span class="at">alpha =</span> <span class="fl">0.5</span>),<span class="st">"blue"</span>),<span class="at">add=</span><span class="cn">TRUE</span>) </span></code></pre></div>
<p><img src="index_GEOG364-22_L7Point_files/figure-html/unnamed-chunk-11-1.png" width="768" /></p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># Slightly transparent points & blue ellipse</span></span></code></pre></div>
<p>standard ellipse resources. Using the workflowy course notes (chapter
9), or resources online (for example <a
href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-statistics/h-how-directional-distribution-standard-deviationa.htm">ARCGIS</a>
or <a href="https://mgimond.github.io/Spatial/chp11_0.html">these other
notes</a>),</p>
<ol start="14" style="list-style-type: decimal">
<li>Using the resources above: describe what a standard ellipse is in
your report. Explain roughly percentage of points fall within this
ellipse and why. (hint levels=0.68).</li>
</ol>
</div>
</div>
<div id="point-pattern-auto-correlation" class="section level2"
number="2.5">
<h2><span class="header-section-number">2.5</span> Point Pattern
auto-correlation</h2>
<p>There are two families of methods we can use to at the
autocorrelation/pattern of the point locations, density based ones or
distance based ones.</p>
<p><strong>Density</strong> based methods look for areas that points are
clustered together and can assess what might be correlated with them.
Density based statistics give us an estimate of first order
autocorrelation e.g. is there a big underlying thing driving the density
of points.</p>
<p><strong>Distance</strong> based statistics give an estimate of second
order autocorrelation e.g. does one point change the probability of
seeing more points (AKA one infectious person is likely to lead to more
in the surrounding area).</p>
<div id="density-based-analyses" class="section level3" number="2.5.1">
<h3><span class="header-section-number">2.5.1</span> Density based
analyses</h3>
<div id="global-density" class="section level4" number="2.5.1.1">
<h4><span class="header-section-number">2.5.1.1</span> Global
density</h4>
<p>The <a
href="https://mgimond.github.io/Spatial/chp11_0.html#global-density"><strong>global
density</strong></a> is simply the number of points per unit area.</p>
<ul>
<li><p>You can calculate the number of points, by calculating the number
of rows e.g. <code>nrow(fossil_sf)</code> (many other methods)</p></li>
<li><p>You can calculate the area IN METRES of our study area
(pennsylvania) by <code>area(state.window)</code></p></li>
</ul>
<p><br></p>
<ol start="15" style="list-style-type: decimal">
<li>Using the hints above, IN R, calculate the number of fossils PER
SQUARE KILOMETER</li>
</ol>
</div>
<div id="local-kernel-density" class="section level4" number="2.5.1.2">
<h4><span class="header-section-number">2.5.1.2</span> Local: Kernel
density</h4>
<p>A famous method of density pattern analysis is kernel density.
Essentially a heatmap of where the points are densest (different to
Getis G because that was about the MARKS of each point) There are some
great tutorials</p>
<ul>
<li>here <a
href="https://mgimond.github.io/Spatial/chp11_0.html#kernel-density"
class="uri">https://mgimond.github.io/Spatial/chp11_0.html#kernel-density</a></li>
<li>and here: <a
href="https://www.youtube.com/watch?v=PBZVTjmhl74&t=495s"
class="uri">https://www.youtube.com/watch?v=PBZVTjmhl74&t=495s</a></li>
</ul>
<p>Here is the code to do it.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># R will work in metres by default, let's switch to km</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> fossil_ppp.km <span class="ot"><-</span> <span class="fu">rescale</span>(fossil_ppp, <span class="dv">1000</span>, <span class="st">"km"</span>)</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># Using a 10km bandwidth (sigma)</span></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>Density_kernel_10 <span class="ot"><-</span> <span class="fu">density</span>(fossil_ppp.km, <span class="at">sigma=</span><span class="dv">10</span>) </span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(Density_kernel_10, <span class="at">main=</span><span class="cn">NULL</span>, <span class="at">las=</span><span class="dv">1</span>)</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="fu">contour</span>(Density_kernel_10, <span class="at">add=</span><span class="cn">TRUE</span>)</span></code></pre></div>
<ol start="16" style="list-style-type: decimal">
<li><p>Get the code above working in your report. Play with the
sigma/bandwidth number (e.g. try 1, 10, 100… ), What does the bandwidth
do?</p></li>
<li><p>What does the density pattern from a small bandwidth (say 10km)
suggest about underlying processes (hint, look at a map of PA). What
about a large bandwidth( say, 50km) suggest about the underlying
processes?</p></li>
</ol>
<div id="linking-kernel-density-and-elevation" class="section level5"
number="2.5.1.2.1">
<h5><span class="header-section-number">2.5.1.2.1</span> Linking kernel
density and elevation</h5>
<p>We can test some of these things by looking at a map of density vs a
covariate. For example elevation:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co"># convert elevation to a special format</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>elev.img <span class="ot"><-</span> <span class="fu">as.im.RasterLayer</span>(elevation.utm)</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="co"># calculate the relationship</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>densityfossil.vs.elevation <span class="ot"><-</span> <span class="fu">rhohat</span>(<span class="fu">unmark</span>(fossil_ppp),elev.img)</span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(densityfossil.vs.elevation)</span></code></pre></div>
<p><img src="index_GEOG364-22_L7Point_files/figure-html/unnamed-chunk-14-1.png" width="768" /></p>
<ol start="18" style="list-style-type: decimal">
<li><p>Get this code working in your report (note, if your computer
didn’t manage to get maptools, just explain and interpret this
output)</p></li>
<li><p>Interpret the plot. The x-axis on this plot is elevation,
e.g. low lying points are to the left and mountainous points on the
right. The y-axis is the density of points in each gridcell.</p></li>
</ol>
<p><em>We can go much further than this at this point, and there are
entire courses on point pattern. If you are interested, see:</em></p>
<ul>
<li><a
href="https://mgimond.github.io/Spatial/point-pattern-analysis-in-r.html#kernel-density-adjusted-for-covariate-1"
class="uri">https://mgimond.github.io/Spatial/point-pattern-analysis-in-r.html#kernel-density-adjusted-for-covariate-1</a></li>
<li><a href="http://spatstat.org/Melb2018/solutions/solution03.html"
class="uri">http://spatstat.org/Melb2018/solutions/solution03.html</a>
(density)</li>
</ul>
</div>
</div>
</div>
<div id="distance-based-analyses" class="section level3" number="2.5.2">
<h3><span class="header-section-number">2.5.2</span> Distance based
analyses</h3>
<div id="global-nearest-neighbour" class="section level4"
number="2.5.2.1">
<h4><span class="header-section-number">2.5.2.1</span> Global: Nearest
neighbour</h4>
<p>The easiest distance based measure is the distance between each point
and its nearest neighbour.</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co">#For each point, nndist calculates the distance to the nearest point </span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>fossil.Nearest_neighbor <span class="ot"><-</span> <span class="fu">nndist</span>(fossil_ppp.km)</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="co"># plot</span></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="fu">hist</span>(fossil.Nearest_neighbor, <span class="at">main=</span><span class="cn">NULL</span>, <span class="at">las=</span><span class="dv">1</span>,</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="at">xlab=</span><span class="fu">list</span>(<span class="st">"Distance between each point and its Nearest Neighbour (km)"</span>,<span class="at">cex=</span>.<span class="dv">8</span>))</span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="co"># look at the summary</span></span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a><span class="fu">skim</span>(fossil.Nearest_neighbor)</span></code></pre></div>
<ol start="20" style="list-style-type: decimal">
<li><p>Get this code running. What distance are 75% of points closer
than? Hhat is the mean distance two points are apart?</p></li>
<li><p>Here is the code for a clark evans test. Write out the hypothesis
test (e.g. H0, H1..) and interpret the results. note, we will do this in
class</p></li>
</ol>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co"># cand </span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clarkevans.test</span>(fossil_ppp.km)</span></code></pre></div>
</div>
<div id="local-l-functions" class="section level4" number="2.5.2.2">
<h4><span class="header-section-number">2.5.2.2</span> Local: L
functions</h4>
<p>Finally, the L function shows whether the data is clustered at
different distances apart. See here for an explanation.</p>
<p><a
href="https://psu-spatial.github.io/Geog364-2021/pg_Tut12_pointpattern.html#L-Function"
class="uri">https://psu-spatial.github.io/Geog364-2021/pg_Tut12_pointpattern.html#L-Function</a></p>
<p>You don’t need to do anything here, I just want you to know the code
and get it running.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Calculate the L function and its uncertainty envelope</span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a>L.DATA <span class="ot"><-</span> <span class="fu">Lest</span>(fossil_ppp.km)</span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Rather than simply saying something is “clustered” or “uniform” </span></span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a><span class="co"># depending on how it subjectively looks to the</span></span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a><span class="co"># IRP line, we can instead use Monte Carlo simulation to assess our data </span></span>
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a><span class="co"># against many L patterns that were caused by an Independent Random Pattern. </span></span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a><span class="co"># Here we generate 100 CSRs and calculate the L function for each one</span></span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> L_DATA_envelope <span class="ot"><-</span> <span class="fu">envelope</span>(fossil_ppp.km, Lest, <span class="at">correction =</span> <span class="st">"Ripley"</span>, </span>
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a> <span class="at">verbose =</span> F,</span>
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a> <span class="at">nsim=</span><span class="dv">200</span>, <span class="at">nrank=</span><span class="dv">1</span>, </span>
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true" tabindex="-1"></a> <span class="at">savepatterns =</span> <span class="cn">TRUE</span>, <span class="at">savefuns =</span> <span class="cn">TRUE</span>)</span>
<span id="cb15-17"><a href="#cb15-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-18"><a href="#cb15-18" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-19"><a href="#cb15-19" aria-hidden="true" tabindex="-1"></a><span class="co"># Plot the raw L-function data for different edge effects. Ignore any warnings</span></span>
<span id="cb15-20"><a href="#cb15-20" aria-hidden="true" tabindex="-1"></a><span class="co">#-----------------------------------------</span></span>
<span id="cb15-21"><a href="#cb15-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">plot</span>(L.DATA, . <span class="sc">-</span> r <span class="sc">~</span> r,</span>
<span id="cb15-22"><a href="#cb15-22" aria-hidden="true" tabindex="-1"></a> <span class="at">ylim=</span><span class="fu">c</span>(<span class="dv">0</span><span class="sc">-</span>(<span class="fu">max</span>(L.DATA<span class="sc">$</span>iso<span class="sc">-</span>L.DATA<span class="sc">$</span>r)),<span class="fu">max</span>(L.DATA<span class="sc">-</span>L.DATA<span class="sc">$</span>r)))</span>
<span id="cb15-23"><a href="#cb15-23" aria-hidden="true" tabindex="-1"></a> <span class="co"># Add the uncertainty envelope.</span></span>
<span id="cb15-24"><a href="#cb15-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">plot</span>(L_DATA_envelope, . <span class="sc">-</span> r <span class="sc">~</span> r,<span class="at">add=</span><span class="cn">TRUE</span>)</span></code></pre></div>
<p><img src="index_GEOG364-22_L7Point_files/figure-html/unnamed-chunk-17-1.png" width="768" /></p>
</div>
</div>
</div>
</div>
<div id="above-beyond" class="section level1" number="3">
<h1><span class="header-section-number">3</span> ABOVE & BEYOND</h1>
<p>To get the 4 marks <strong>CHOOSE ONE</strong> of these options AND
EXPLAIN WHAT YOU DID.</p>
<ul>
<li>OPTION 1: Try the fancy plot challenge in step 11 above</li>
</ul>
<p><br></p>
<ul>
<li>OPTION 2: Fully and completely interpret the L analysis above,
including explaining what a Monte Carlo process is and what the cloud
means</li>
</ul>
<p><br></p>
<p>Or….. OPTION: 3 the old school ‘show me something new’</p>
<ul>
<li>You get 2/4 for doing something new in any way</li>
<li>You get 4/4 for something really impressive</li>
</ul>
<p>To help with this, you could also look at some other point pattern
tutorials because they are all linked into spatstat. There are loads of
things you could do to build your knowledge of point pattern
analysis</p>
<ul>
<li><a href="http://spatstat.org/Melb2018/solutions/solution03.html"
class="uri">http://spatstat.org/Melb2018/solutions/solution03.html</a>
(density)</li>
<li><a href="http://spatstat.org/Melb2018/solutions/solution04.html"
class="uri">http://spatstat.org/Melb2018/solutions/solution04.html</a>
(poisson)</li>
<li><a href="http://spatstat.org/Melb2018/solutions/solution05.html"
class="uri">http://spatstat.org/Melb2018/solutions/solution05.html</a>
(marked)</li>
<li><a href="http://spatstat.org/Melb2018/solutions/solution06.html"
class="uri">http://spatstat.org/Melb2018/solutions/solution06.html</a>
(K and L functions)</li>
<li><a
href="https://mgimond.github.io/Spatial/point-pattern-analysis-in-r.html"
class="uri">https://mgimond.github.io/Spatial/point-pattern-analysis-in-r.html</a></li>
<li><a
href="https://bhaskarvk.github.io/user2017.geodataviz/notebooks/02-Static-Maps.nb.html"
class="uri">https://bhaskarvk.github.io/user2017.geodataviz/notebooks/02-Static-Maps.nb.html</a><br />
</li>
<li><a
href="https://bookdown.org/yihui/rmarkdown-cookbook/bibliography.html"
class="uri">https://bookdown.org/yihui/rmarkdown-cookbook/bibliography.html</a></li>
<li><a href="https://www.r-bloggers.com/2018/08/how-to-cite-packages/"
class="uri">https://www.r-bloggers.com/2018/08/how-to-cite-packages/</a></li>
</ul>
<p>Remember to say what you did in the report.</p>
</div>
<div id="predict-your-grade" class="section level1" number="4">
<h1><span class="header-section-number">4</span> Predict your grade</h1>
<p><strong>HTML AND RMD FILE SUBMISSION - 20 marks</strong></p>
<p><strong>REPORT STYLE: Text/Markdown/code style - 10
MARKS</strong></p>
<p><strong>REPORT COMPLETENESS</strong> - are all the steps followed? -
10 MARKS</p>
<p><strong>DATASET BACKGROUND </strong> - 10 MARKS</p>
<ul>
<li>I am assessing you both on knowing WHAT to include and on your
communication</li>
</ul>
<p><strong>BEAUTIFUL MAPS</strong> - 10 MARKS</p>
<ul>
<li>This includes understanding the projection of the
data/graphics.</li>
</ul>
<p><strong>POINT PATTERN DESCRIPTIVE STATS AND STANDARD ELLIPSE</strong>
- 10 MARKS</p>
<p><strong>DENSITY BASED MEASURES</strong> - 10 MARKS</p>
<p><strong>DISTANCE BASED MEASURES Inc hyp test</strong> - 16 MARKS</p>
<p><strong>ABOVE AND BEYOND</strong> (4 Marks). You MUST write what you
did, see above for instructions.</p>
<p>**</p>
<div id="what-your-grade-means" class="section level2" number="4.1">
<h2><span class="header-section-number">4.1</span> What your grade
means</h2>
<p>Why is 100% hard? Overall, here is what your lab should correspond
to:</p>
<table class=" lightable-classic-2 table table-striped table-hover table-responsive" style="font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;">
Grade
</th>
<th style="text-align:left;">
% Mark
</th>
<th style="text-align:left;">
Rubric
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">
A*
</td>
<td style="text-align:left;">
98-100
</td>
<td style="text-align:left;">
Exceptional. Not only was it near perfect, but the graders learned
something. THIS IS HARD TO GET.
</td>
</tr>
<tr>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
96+
</td>
<td style="text-align:left;">
You went above and beyond
</td>
</tr>
<tr>
<td style="text-align:left;">
A
</td>
<td style="text-align:left;">
94+:
</td>
<td style="text-align:left;">
Everything asked for with high quality. Class example
</td>
</tr>
<tr>
<td style="text-align:left;">
A-
</td>
<td style="text-align:left;">
90+
</td>
<td style="text-align:left;">
The odd minor mistake, All code done but not written up in full
sentences etc. A little less care
</td>
</tr>
<tr>
<td style="text-align:left;">
B+
</td>
<td style="text-align:left;">
87+
</td>
<td style="text-align:left;">
More minor mistakes. Things like missing units, getting the odd
question wrong, no workings shown
</td>
</tr>
<tr>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
84+
</td>
<td style="text-align:left;">
Solid work but the odd larger mistake or missing answer. Completely
misinterpreted something, that type of thing
</td>
</tr>
<tr>
<td style="text-align:left;">
B-
</td>
<td style="text-align:left;">
80+
</td>
<td style="text-align:left;">
Starting to miss entire/questions sections, or multiple larger mistakes.
Still a solid attempt.
</td>