-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
executable file
·802 lines (777 loc) · 87.4 KB
/
index.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.1.189">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Manny Gimond">
<title>Tissot’s Indicatrix</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
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;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="index_files/libs/clipboard/clipboard.min.js"></script>
<script src="index_files/libs/quarto-html/quarto.js"></script>
<script src="index_files/libs/quarto-html/popper.min.js"></script>
<script src="index_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="index_files/libs/quarto-html/anchor.min.js"></script>
<link href="index_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="index_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="index_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="index_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="index_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
</head>
<body>
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#introduction" id="toc-introduction" class="nav-link active" data-scroll-target="#introduction">Introduction</a></li>
<li><a href="#generating-tissot-circles" id="toc-generating-tissot-circles" class="nav-link" data-scroll-target="#generating-tissot-circles">Generating Tissot circles</a>
<ul class="collapse">
<li><a href="#loading-a-few-functions-and-base-layers" id="toc-loading-a-few-functions-and-base-layers" class="nav-link" data-scroll-target="#loading-a-few-functions-and-base-layers">Loading a few functions and base layers</a></li>
<li><a href="#defining-a-few-projections" id="toc-defining-a-few-projections" class="nav-link" data-scroll-target="#defining-a-few-projections">Defining a few projections</a></li>
<li><a href="#mercator-projection-indicatrix" id="toc-mercator-projection-indicatrix" class="nav-link" data-scroll-target="#mercator-projection-indicatrix">Mercator projection indicatrix</a></li>
<li><a href="#creating-a-custom-function" id="toc-creating-a-custom-function" class="nav-link" data-scroll-target="#creating-a-custom-function">Creating a custom function</a></li>
<li><a href="#equal-area-cylindrical-projection" id="toc-equal-area-cylindrical-projection" class="nav-link" data-scroll-target="#equal-area-cylindrical-projection">Equal area cylindrical projection</a></li>
<li><a href="#earth-from-space-planar-projection" id="toc-earth-from-space-planar-projection" class="nav-link" data-scroll-target="#earth-from-space-planar-projection">Earth-from-space planar projection</a></li>
<li><a href="#usa-contiguous-lambert-conformal-conic-projection" id="toc-usa-contiguous-lambert-conformal-conic-projection" class="nav-link" data-scroll-target="#usa-contiguous-lambert-conformal-conic-projection">USA Contiguous Lambert Conformal Conic Projection</a></li>
</ul></li>
<li><a href="#generating-areal-scale-factor-rasters" id="toc-generating-areal-scale-factor-rasters" class="nav-link" data-scroll-target="#generating-areal-scale-factor-rasters">Generating areal scale factor rasters</a>
<ul class="collapse">
<li><a href="#orthographic-projection" id="toc-orthographic-projection" class="nav-link" data-scroll-target="#orthographic-projection">Orthographic projection</a></li>
<li><a href="#utm-projection" id="toc-utm-projection" class="nav-link" data-scroll-target="#utm-projection">UTM projection</a></li>
<li><a href="#plate-carrée-projection" id="toc-plate-carrée-projection" class="nav-link" data-scroll-target="#plate-carrée-projection">Plate Carrée projection</a></li>
<li><a href="#equal-area-projection" id="toc-equal-area-projection" class="nav-link" data-scroll-target="#equal-area-projection">Equal-area projection</a></li>
</ul></li>
<li><a href="#combining-indicatrix-with-areal-scale-factor-raster" id="toc-combining-indicatrix-with-areal-scale-factor-raster" class="nav-link" data-scroll-target="#combining-indicatrix-with-areal-scale-factor-raster">Combining indicatrix with areal scale factor raster</a>
<ul class="collapse">
<li><a href="#equal-area-projection-1" id="toc-equal-area-projection-1" class="nav-link" data-scroll-target="#equal-area-projection-1">Equal-area projection</a></li>
<li><a href="#gnomonic-projection" id="toc-gnomonic-projection" class="nav-link" data-scroll-target="#gnomonic-projection">Gnomonic projection</a></li>
<li><a href="#equidistance-conical-projection" id="toc-equidistance-conical-projection" class="nav-link" data-scroll-target="#equidistance-conical-projection">Equidistance conical projection</a></li>
</ul></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Tissot’s Indicatrix</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Manny Gimond </p>
</div>
</div>
</div>
</header>
<hr>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>When converting spatial features from a geographic coordinate system (GSC) to a projected coordinate system (PCS) one or more spatial properties may be distorted in the transformation. These properties include <strong>area</strong>, <strong>shape</strong>, <strong>distance</strong> and <strong>direction</strong> .</p>
<p>Nicolas Tissot’s <em>indicatrix</em> is designed to quantify the level of distortion in a map projection. The idea is to project a small circle (i.e. small enough so that the distortion remains relatively uniform across the circle’s extent) and to measure its distorted shape on the projected map.</p>
<p>For example, the following figure shows the distorted circles at different locations in North America when presented in a Mollweide projection whose central meridian is centered in the middle on the 48 states at 100°W.</p>
<div class="cell">
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid" width="480"></p>
</div>
</div>
<p>Let’s explore a Tissot indicatrix (TI) in more detail at 125°W and 60°N in the Mollweide projection.</p>
<div class="cell">
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid" width="480"></p>
</div>
</div>
<p>The <strong>red distorted ellipse</strong> (the indicatrix) is the transformed circle in this particular projection (+proj=moll +lon_0=-100 +x_0=0 +y_0=0 +datum=WGS84). The <strong>green</strong> and <strong>red</strong> lines show the magnitude and direction of the ellipse’s major and minor axes respectively. If these axes are not equal (i.e. if the ellipse has a non-zero eccentricity), the projection is said <em>not</em> to be <strong>conformal</strong> at this location. These lines can also be used to assess scale distortion which can vary as a function of bearing as seen in this example. The green line shows maximum scale distortion and the red line shows minimum scale distortion–these are sometimes referred to as the <strong>principal directions</strong>. In this working example, the principal directions are 1.227 and 0.812 respectively. A scale value of <code>1</code> indicates no distortion. A value less than <code>1</code> indicates a smaller-than-true scale and a value greater than <code>1</code> indicates a greater-than-true scale.</p>
<p>Not only can shape be distorted, but its <strong>area</strong> can be as well. The bisque colored circle at the center of the ellipse represents a <strong>base circle</strong> as represented by this Mollweide projection. It’s smaller than the indicatrix. The indicatrix is about 0.997 times smaller than the base circle. In other words, an area will be exaggerated 0.997 times at this location given this projection.</p>
<p>Other features of this indicatrix include The <strong>north-south</strong> grey line which is aligned with the meridian and the <strong>east-west</strong> grey line which is aligned with the parallel. These lines are used to assess if meridians and parallels intersect at right angles.</p>
</section>
<section id="generating-tissot-circles" class="level2">
<h2 class="anchored" data-anchor-id="generating-tissot-circles">Generating Tissot circles</h2>
<section id="loading-a-few-functions-and-base-layers" class="level3">
<h3 class="anchored" data-anchor-id="loading-a-few-functions-and-base-layers">Loading a few functions and base layers</h3>
<p>A group of functions are available on the github website and can be sourced via:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Load functions used in this tutorial</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">source</span>(<span class="st">"https://raw.githubusercontent.com/mgimond/tissot/master/Tissot_functions.R"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>This tutorial will also make use of a few base layers that will be used as a reference.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>world <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="fu">gzcon</span>(<span class="fu">url</span>(<span class="st">"https://github.com/mgimond/tissot/raw/master/smpl_world.rds"</span>)))</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>us <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="fu">gzcon</span>(<span class="fu">url</span>(<span class="st">"https://github.com/mgimond/tissot/raw/master/smpl_US.rds"</span>)))</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Change US lon values from 0:360 to -180:180</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>us.crs <span class="ot"><-</span> <span class="fu">st_crs</span>(us)</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="fu">st_geometry</span>(us) <span class="ot"><-</span> <span class="fu">st_geometry</span>(us) <span class="sc">+</span> <span class="fu">c</span>(<span class="sc">-</span><span class="dv">360</span>, <span class="dv">0</span>) </span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="fu">st_crs</span>(us) <span class="ot"><-</span> us.crs</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="defining-a-few-projections" class="level3">
<h3 class="anchored" data-anchor-id="defining-a-few-projections">Defining a few projections</h3>
<p>In this next code chunk, we’ll create a few projection objects for use later in this tutorial.</p>
<blockquote class="blockquote">
<p>Note 1: PROJ string syntax is used to define projections in this tutorial. This may generate warnings when running some R scripts given that <a href="https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems">WKT</a> format is now becoming a preferred projection format.</p>
</blockquote>
<blockquote class="blockquote">
<p>Note 2: Modifying a projection’s tangent or secant coordinate values may result in distorted base maps and/or errors in the underlying modified geometry if the new projection forces a merging of vector layers across the date line.</p>
</blockquote>
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>proj.rob <span class="ot"><-</span> <span class="st">"+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84"</span> <span class="co"># Robinson</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>proj.aea <span class="ot"><-</span> <span class="st">"+proj=aea +lat_1=30 +lat_2=45 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"</span> <span class="co"># Equal area conic</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>proj.eqdc <span class="ot"><-</span> <span class="st">"+proj=eqdc +lat_0=37.5 +lon_0=-96 +lat_1=30 +lat_2=45"</span> <span class="co"># Equidistant conic</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>proj.merc <span class="ot"><-</span> <span class="st">"+proj=merc +ellps=WGS84"</span> <span class="co"># Mercator</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>proj.ortho1 <span class="ot"><-</span> <span class="st">"+proj=ortho +lon_0=-69 +lat_0=45 +ellps=WGS84"</span> <span class="co"># Planar projection</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>proj.utm19N <span class="ot"><-</span> <span class="st">"+proj=utm +zone=19 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"</span> <span class="co"># UTM NAD83</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>proj.cea <span class="ot"><-</span> <span class="st">"+proj=cea +lon_0=0 +lat_ts=0"</span> <span class="co"># Equal Area Cylindrical projection.</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>proj.carree <span class="ot"><-</span> <span class="st">"+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 </span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="st"> +datum=WGS84 +units=m +no_defs"</span> <span class="co"># Plate Carree</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a>proj.aeqd <span class="ot"><-</span> <span class="st">"+proj=aeqd +lat_0=45 +lon_0=-69 +x_0=0 +y_0=0 +ellps=WGS84 </span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="st"> +datum=WGS84 +units=m +no_defs"</span> <span class="co"># Azimuthal Equidistant</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a>proj.gnom <span class="ot"><-</span> <span class="st">"+proj=gnom +lon_0=-100 +lat_0=30"</span> <span class="co"># Gnomonic</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a>proj.lcc <span class="ot"><-</span> <span class="st">"+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 +datum=NAD83"</span> <span class="co"># USA Lambert Conformal</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>We’ll also define the input coordinate system used throughout this exercise (WGS 1984 GCS). This CS will be used to define the lat/long values of the TI centers.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>proj.in <span class="ot"><-</span> <span class="dv">4326</span> <span class="co"># EPSG code for WGS 1984 GCS</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="mercator-projection-indicatrix" class="level3">
<h3 class="anchored" data-anchor-id="mercator-projection-indicatrix">Mercator projection indicatrix</h3>
<p>We’ll start off by exploring a <strong>Mercator</strong> projection (a popular projection found on many mapping websites).</p>
<p>First, we’ll define point locations where we will want to evaluate projection distortions. We’ll automate the point creation process by <em>gridding</em> the point distribution.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">80</span>,<span class="dv">80</span>, <span class="at">by=</span>20L)</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">170</span>,<span class="dv">170</span>, <span class="at">by=</span>34L)</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>coord <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">expand.grid</span>(lon,lat))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Next, we’ll run the <code>coord_check()</code> function (one of the functions sourced earlier in this tutorial) to remove any points that may fall outside of the Mercator’s practical extent.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>coord2 <span class="ot"><-</span> <span class="fu">coord_check</span>(coord, <span class="at">proj.out =</span> proj.merc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Next, we’ll generate the indicatrix parameters for these points using the custom <code>ti()</code> function.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>i.lst <span class="ot"><-</span> <span class="fu">apply</span>(coord2,<span class="dv">1</span>, <span class="cf">function</span>(x) <span class="fu">ti</span>(<span class="at">coord =</span> x, <span class="at">proj.out =</span> proj.merc))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Next, we’ll create <code>sf</code> objects from these indicatrix parameters.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>tsf <span class="ot"><-</span> <span class="fu">tissot_sf</span>(i.lst, <span class="at">proj.out =</span> proj.merc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>The output object <code>tsf</code> is a list consisting of the different indicatrix <code>sf</code> features. Each feature can be extracted from the list via its component name:</p>
<ul>
<li><code>tsf$base</code> The base circle as represented by the projected CS (polygon)</li>
<li><code>tsf$ind</code> The indicatrix (polygon)</li>
<li><code>tsf$maja</code> The semi-major axis (polyline)</li>
<li><code>tsf$mina</code> The semi-minor axis (polyline)</li>
<li><code>tsf$lam</code> The parallel (polyline)</li>
<li><code>tsf$phi</code> The meridian (polyline)</li>
</ul>
<p>Finally, we’ll plot the ellipses using the <code>ggplot2</code> package.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>world.merc <span class="ot"><-</span> <span class="fu">st_transform</span>(world, proj.merc) <span class="co"># Project world map</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>() <span class="sc">+</span> </span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> world.merc, <span class="at">fill =</span> <span class="st">"grey90"</span>, <span class="at">col =</span> <span class="st">"white"</span>) <span class="sc">+</span> </span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>base, <span class="at">fill =</span> <span class="st">"bisque"</span>, <span class="at">col =</span> <span class="st">"grey50"</span>) <span class="sc">+</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>ind, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>mina, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>maja, <span class="at">col=</span><span class="st">"green"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>lam, <span class="at">col=</span><span class="st">"grey50"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>phi, <span class="at">col=</span><span class="st">"grey80"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_sf</span>(<span class="at">ylim=</span><span class="fu">c</span>(<span class="sc">-</span><span class="dv">18800000</span>,<span class="dv">18800000</span>), <span class="at">crs =</span> proj.merc) <span class="sc">+</span></span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-11-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>The Mercator projection is conformal in that the shape of the circle remains a circle. Also, its lines of longitude and latitude remain at right angles across the entire map extent. Its area, however, is heavily distorted as one approaches the poles (recall that the red circles represent the <em>true</em> circle and the bisque colored circles are the projection’s rendering of the circle in its own coordinate system).</p>
<p>A separate function, <code>TI_local()</code> is available that allows you to explore the indicatrix in more detail at a single point location. For example, to explore the Mercator distortion at a location in central Maine (USA), type:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>ti.maine <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="fl">44.5</span>, <span class="at">proj.out =</span> proj.merc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-12-1.png" class="img-fluid" width="480"></p>
</div>
</div>
<p>You can extract indicatrix parameters from the <code>ti.maine</code> object generated from this function. For example, to extract the area scale, type:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>ti.maine<span class="sc">$</span>scale.area</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.959244</code></pre>
</div>
</div>
<p>Likewise, to extract the principal direction (length) scales, type:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>ti.maine<span class="sc">$</span>max.scale</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.399736</code></pre>
</div>
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>ti.maine<span class="sc">$</span>min.scale</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.399725</code></pre>
</div>
</div>
</section>
<section id="creating-a-custom-function" class="level3">
<h3 class="anchored" data-anchor-id="creating-a-custom-function">Creating a custom function</h3>
<p>Going forward, we will rerun many of the code chunks executed earlier in this exercise. To reduce code clutter, we will create a custom function that will take as input projection type (<code>proj.out</code>) and tissot center locations.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sf_use_s2</span>(<span class="cn">FALSE</span>) </span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>ti.out <span class="ot"><-</span> <span class="cf">function</span>(<span class="at">proj.in =</span> proj.in, proj.out, lat, lon, <span class="at">bmap =</span> world, </span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> <span class="at">plot =</span> <span class="cn">TRUE</span>){</span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> coord1 <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">expand.grid</span>(lon,lat))</span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a> coord2 <span class="ot"><-</span> <span class="fu">coord_check</span>(<span class="at">lonlat =</span>coord1, <span class="at">proj.out =</span> proj.out)</span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a> i.lst <span class="ot"><-</span> <span class="fu">apply</span>(coord2,<span class="dv">1</span>, <span class="cf">function</span>(x) <span class="fu">ti</span>(<span class="at">coord =</span> x, <span class="at">proj.out =</span> proj.out))</span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a> tsf <span class="ot"><-</span> <span class="fu">tissot_sf</span>(i.lst, <span class="at">proj.out =</span> proj.out)</span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span>(plot <span class="sc">==</span> <span class="cn">TRUE</span>){</span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># Re-project the world</span></span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> bmap.prj <span class="ot"><-</span> <span class="fu">st_transform</span>(bmap, <span class="at">crs =</span> proj.out, <span class="at">check =</span> <span class="cn">TRUE</span>)</span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>() <span class="sc">+</span> </span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> bmap.prj, <span class="at">fill =</span> <span class="st">"grey90"</span>, <span class="at">col =</span> <span class="st">"white"</span>) <span class="sc">+</span> </span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>base, <span class="at">fill =</span> <span class="st">"bisque"</span>, <span class="at">col =</span> <span class="st">"grey50"</span>) <span class="sc">+</span></span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>ind, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>mina, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>maja, <span class="at">col=</span><span class="st">"green"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>lam, <span class="at">col=</span><span class="st">"grey50"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb17-20"><a href="#cb17-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>phi, <span class="at">col=</span><span class="st">"grey80"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb17-21"><a href="#cb17-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span>
<span id="cb17-22"><a href="#cb17-22" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span>{</span>
<span id="cb17-23"><a href="#cb17-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(tsf)</span>
<span id="cb17-24"><a href="#cb17-24" aria-hidden="true" tabindex="-1"></a> }</span>
<span id="cb17-25"><a href="#cb17-25" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="equal-area-cylindrical-projection" class="level3">
<h3 class="anchored" data-anchor-id="equal-area-cylindrical-projection">Equal area cylindrical projection</h3>
<p>Next, we’ll explore another cylindrical coordinate system that, unlike the Mercator projection, preserves area.</p>
<p>We’ll run the same code chunks used in the last section, but we’ll replace all references to the output projected coordinate system with the <code>proj.cea</code> projection object.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Define point coordinates for TI polygons</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">80</span>, <span class="dv">80</span>, <span class="at">by =</span> 20L)</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">170</span>, <span class="dv">170</span>, <span class="at">by =</span> 34L) </span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate map</span></span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a><span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.cea, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-16-1.png" class="img-fluid" width="672"></p>
</div>
</div>
<p>Note the flattening of features as one progresses pole-ward. This compensates for the east-west stretching of features nearer the poles. Let’s check an indicatrix up close at the 44.5° latitude.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>ti.maine <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="fl">44.5</span>, <span class="at">proj.out =</span> proj.cea)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-17-1.png" class="img-fluid" width="480"></p>
</div>
</div>
<p>The area is indeed preserved, but this comes at a cost. The projection is not conformal except near the equator (this is where the projection makes contact with the earth’s spheroid). At 44.5°N the east-west scale is increased by 1.4 and the north-south scale is decreased by 0.7.</p>
</section>
<section id="earth-from-space-planar-projection" class="level3">
<h3 class="anchored" data-anchor-id="earth-from-space-planar-projection">Earth-from-space planar projection</h3>
<p>Let’s explore another family of projections: the orthographic projection.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="dv">0</span>, <span class="dv">60</span>, <span class="at">by =</span> 15L)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">140</span>, <span class="dv">0</span>, <span class="at">by =</span> 35L)</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.ortho1, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-18-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>This particular coordinate system has the center of the projection touching the earth’s surface at -69°W and 45°N. As such, minimal distortion will occur at the center of this projection.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>ti.maine <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="dv">69</span>, <span class="at">lat =</span> <span class="dv">45</span>, <span class="at">proj.out =</span> proj.ortho1)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-19-1.png" class="img-fluid" width="480"></p>
</div>
</div>
<p>Distortion in area and length increases as one moves away from the projection’s center as shown in the next TI centered at 0° longitude and 80° latitude.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="dv">0</span>, <span class="at">lat =</span> <span class="dv">80</span>, <span class="at">proj.out =</span> proj.ortho1)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-20-1.png" class="img-fluid" width="480"></p>
</div>
</div>
</section>
<section id="usa-contiguous-lambert-conformal-conic-projection" class="level3">
<h3 class="anchored" data-anchor-id="usa-contiguous-lambert-conformal-conic-projection">USA Contiguous Lambert Conformal Conic Projection</h3>
<p>This next projection is designed to preserve shape within its extent.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="dv">20</span>, <span class="dv">60</span>, <span class="at">by =</span> 20L)</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">150</span>, <span class="sc">-</span><span class="dv">50</span>, <span class="at">by =</span> 30L)</span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a><span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.lcc, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon, <span class="at">bmap =</span> us)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-21-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>Let’s explore one of the TI polygons in greater detail. We’ll zoom in on (60°N, 130°W).</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>ti_lcc <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="dv">130</span>, <span class="at">lat =</span> <span class="dv">60</span>, <span class="at">proj.out =</span> proj.lcc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-22-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>The principal directions (smallest and largest axes) are equal suggestion that shape is preserved. Another way we can quantify the distortion in shape is by extracting the angle between the parallel and meridian lines at the <code>TI</code>’s center from the <code>ti_lcc</code> object (these are shown as the two grey lines in the <code>TI</code>). A conformal projection is one that preserves angle, so we would expect a value of 90° between the two reference lines.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>ti_lcc[[<span class="dv">12</span>]][<span class="dv">3</span>] <span class="co"># Extract the intersecting angle</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>intersection_angle
89.99917 </code></pre>
</div>
</div>
<p>This is very close to 90°. But it comes at a cost: distortions in area and length scales.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>ti_lcc<span class="sc">$</span>scale.area</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.154365</code></pre>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a>ti_lcc<span class="sc">$</span>max.scale</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.074422</code></pre>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb31"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a>ti_lcc<span class="sc">$</span>min.scale</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1.074405</code></pre>
</div>
</div>
</section>
</section>
<section id="generating-areal-scale-factor-rasters" class="level2">
<h2 class="anchored" data-anchor-id="generating-areal-scale-factor-rasters">Generating areal scale factor rasters</h2>
<p>We can generate a continuous (raster) surface of areal scale values. This can prove helpful in visualizing the distortion associated with the PCS across the <em>whole</em> map extent.</p>
<p>We’ll first create a custom function whereby areal scales less than one will be assigned a <strong>red hue</strong>, areal scales greater than one will be assigned a <strong>blueish hue</strong>, and scales close to one will be assigned a <strong>yellow hue</strong>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb33"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(raster)</span>
<span id="cb33-2"><a href="#cb33-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-3"><a href="#cb33-3" aria-hidden="true" tabindex="-1"></a><span class="fu">sf_use_s2</span>(<span class="cn">FALSE</span>) <span class="co"># Needed when cropping over large lon range</span></span>
<span id="cb33-4"><a href="#cb33-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-5"><a href="#cb33-5" aria-hidden="true" tabindex="-1"></a>r.out <span class="ot"><-</span> <span class="cf">function</span>(ll, ur, proj.out, <span class="at">plot =</span> <span class="cn">TRUE</span>, <span class="at">bgmap =</span> world,</span>
<span id="cb33-6"><a href="#cb33-6" aria-hidden="true" tabindex="-1"></a> <span class="at">nrows =</span> <span class="dv">14</span>, <span class="at">ncols =</span> <span class="dv">16</span>) {</span>
<span id="cb33-7"><a href="#cb33-7" aria-hidden="true" tabindex="-1"></a> ll.prj <span class="ot"><-</span> <span class="fu">prj2</span>(ll, <span class="at">proj.out =</span> proj.out)</span>
<span id="cb33-8"><a href="#cb33-8" aria-hidden="true" tabindex="-1"></a> ur.prj <span class="ot"><-</span> <span class="fu">prj2</span>(ur, <span class="at">proj.out =</span> proj.out)</span>
<span id="cb33-9"><a href="#cb33-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-10"><a href="#cb33-10" aria-hidden="true" tabindex="-1"></a><span class="co"># Define raster extent in the native PCS (note that the choice of extent and </span></span>
<span id="cb33-11"><a href="#cb33-11" aria-hidden="true" tabindex="-1"></a><span class="co"># grid size may generate instabilities in the projected values)</span></span>
<span id="cb33-12"><a href="#cb33-12" aria-hidden="true" tabindex="-1"></a>ext.prj <span class="ot"><-</span> <span class="fu">extent</span>(<span class="fu">matrix</span>(<span class="fu">c</span>(ll.prj[<span class="dv">1</span>], ll.prj[<span class="dv">2</span>], ur.prj[<span class="dv">1</span>], ur.prj[<span class="dv">2</span>]), <span class="at">nrow=</span><span class="dv">2</span>))</span>
<span id="cb33-13"><a href="#cb33-13" aria-hidden="true" tabindex="-1"></a>r <span class="ot"><-</span> <span class="fu">raster</span>(ext.prj, <span class="at">nrows=</span>nrows, <span class="at">ncols=</span>ncols, <span class="at">crs=</span>proj.out, <span class="at">vals=</span><span class="cn">NA</span>)</span>
<span id="cb33-14"><a href="#cb33-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-15"><a href="#cb33-15" aria-hidden="true" tabindex="-1"></a><span class="co"># Extracts coordinate values in native PCS</span></span>
<span id="cb33-16"><a href="#cb33-16" aria-hidden="true" tabindex="-1"></a>coord.prj <span class="ot"><-</span> raster<span class="sc">::</span><span class="fu">coordinates</span>(r) </span>
<span id="cb33-17"><a href="#cb33-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-18"><a href="#cb33-18" aria-hidden="true" tabindex="-1"></a><span class="co"># Now convert to lat/long values </span></span>
<span id="cb33-19"><a href="#cb33-19" aria-hidden="true" tabindex="-1"></a><span class="co"># Note that we are reversing the transformation direction, we are going</span></span>
<span id="cb33-20"><a href="#cb33-20" aria-hidden="true" tabindex="-1"></a><span class="co"># from projected to geographic.</span></span>
<span id="cb33-21"><a href="#cb33-21" aria-hidden="true" tabindex="-1"></a>coord.ll <span class="ot"><-</span> <span class="fu">t</span>(<span class="fu">apply</span>(coord.prj, <span class="dv">1</span>,</span>
<span id="cb33-22"><a href="#cb33-22" aria-hidden="true" tabindex="-1"></a> <span class="at">FUN =</span> <span class="cf">function</span>(x) <span class="fu">prj2</span>(x, <span class="at">proj.in =</span> proj.out,</span>
<span id="cb33-23"><a href="#cb33-23" aria-hidden="true" tabindex="-1"></a> <span class="at">proj.out=</span><span class="st">"+proj=longlat +datum=WGS84"</span>)))</span>
<span id="cb33-24"><a href="#cb33-24" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb33-25"><a href="#cb33-25" aria-hidden="true" tabindex="-1"></a><span class="co"># Compute Tissot area</span></span>
<span id="cb33-26"><a href="#cb33-26" aria-hidden="true" tabindex="-1"></a>i.lst <span class="ot"><-</span> <span class="fu">apply</span>(coord.ll, <span class="dv">1</span>, <span class="cf">function</span>(x) <span class="fu">ti_area</span>(<span class="at">coord=</span>x, <span class="at">proj.out =</span> proj.out))</span>
<span id="cb33-27"><a href="#cb33-27" aria-hidden="true" tabindex="-1"></a>r[] <span class="ot"><-</span> <span class="fu">round</span>(i.lst,<span class="dv">4</span>)</span>
<span id="cb33-28"><a href="#cb33-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-29"><a href="#cb33-29" aria-hidden="true" tabindex="-1"></a><span class="co"># Re-project the world</span></span>
<span id="cb33-30"><a href="#cb33-30" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-31"><a href="#cb33-31" aria-hidden="true" tabindex="-1"></a> bgmap.crp <span class="ot"><-</span> <span class="fu">st_crop</span>(bgmap, <span class="fu">c</span>(ll,ur) )</span>
<span id="cb33-32"><a href="#cb33-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">st_is_valid</span>(bgmap.crp)</span>
<span id="cb33-33"><a href="#cb33-33" aria-hidden="true" tabindex="-1"></a> bgmap.prj <span class="ot"><-</span> <span class="fu">st_transform</span>(bgmap.crp, <span class="at">crs =</span> <span class="fu">st_crs</span>(proj.out), <span class="at">partial =</span> <span class="cn">TRUE</span>)</span>
<span id="cb33-34"><a href="#cb33-34" aria-hidden="true" tabindex="-1"></a><span class="co"># Some polygons may need to be removed if invalid</span></span>
<span id="cb33-35"><a href="#cb33-35" aria-hidden="true" tabindex="-1"></a> valid <span class="ot"><-</span> <span class="fu">st_is_valid</span>(bgmap.prj)</span>
<span id="cb33-36"><a href="#cb33-36" aria-hidden="true" tabindex="-1"></a> bgmap.prj <span class="ot"><-</span> bgmap.prj[valid, ]</span>
<span id="cb33-37"><a href="#cb33-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-38"><a href="#cb33-38" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb33-39"><a href="#cb33-39" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">ggplot</span>()<span class="sc">+</span></span>
<span id="cb33-40"><a href="#cb33-40" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_raster</span>(<span class="at">data =</span> <span class="fu">as.data.frame</span>(r, <span class="at">xy =</span> <span class="cn">TRUE</span>), <span class="at">interpolate =</span> <span class="cn">TRUE</span>,</span>
<span id="cb33-41"><a href="#cb33-41" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>x,<span class="at">y=</span>y, <span class="at">fill =</span> layer), <span class="at">alpha =</span> <span class="fl">0.7</span>) <span class="sc">+</span></span>
<span id="cb33-42"><a href="#cb33-42" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_gradient2</span>(<span class="at">low =</span> <span class="st">"red"</span>, <span class="at">midpoint =</span> <span class="dv">1</span>, <span class="at">mid =</span> <span class="st">"yellow"</span>, <span class="at">high =</span> <span class="st">"blue"</span>)<span class="sc">+</span></span>
<span id="cb33-43"><a href="#cb33-43" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> bgmap.prj, <span class="at">col =</span> <span class="st">"black"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb33-44"><a href="#cb33-44" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_sf</span>(<span class="at">xlim =</span> <span class="fu">extent</span>(r)[<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>,], <span class="at">ylim =</span> <span class="fu">extent</span>(r)[<span class="dv">3</span><span class="sc">:</span><span class="dv">4</span>,]) <span class="sc">+</span></span>
<span id="cb33-45"><a href="#cb33-45" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">fill =</span> <span class="fu">guide_colourbar</span>(<span class="at">title =</span> <span class="st">"Area scale"</span>))</span>
<span id="cb33-46"><a href="#cb33-46" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb33-47"><a href="#cb33-47" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> (plot <span class="sc">==</span> <span class="cn">TRUE</span>){</span>
<span id="cb33-48"><a href="#cb33-48" aria-hidden="true" tabindex="-1"></a> out</span>
<span id="cb33-49"><a href="#cb33-49" aria-hidden="true" tabindex="-1"></a>}<span class="cf">else</span>{</span>
<span id="cb33-50"><a href="#cb33-50" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(r)</span>
<span id="cb33-51"><a href="#cb33-51" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb33-52"><a href="#cb33-52" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<section id="orthographic-projection" class="level3">
<h3 class="anchored" data-anchor-id="orthographic-projection">Orthographic projection</h3>
<p>We’ll extend our analysis of the orthographic projection from the last section.</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-27_c9981b699670495ec659acc8662caf5b">
<div class="sourceCode cell-code" id="cb34"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">120</span>, <span class="at">ymin =</span> <span class="sc">-</span><span class="dv">20</span>)</span>
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="dv">40</span>, <span class="at">ymax =</span> <span class="dv">60</span>)</span>
<span id="cb34-3"><a href="#cb34-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb34-4"><a href="#cb34-4" aria-hidden="true" tabindex="-1"></a><span class="fu">r.out</span>(ll, ur, proj.ortho1, <span class="at">plot =</span> <span class="cn">TRUE</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-27-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>This orthographic projection has a true scale centered at 69° West and and 45° North (the coordinate system’s custom center). The areal scale fraction decreases as one moves away from the point. Yellow hue is assigned a scale of one (i.e. minimal areal distortion). Given its areal and conformal distortions, this projection is not particularly useful other than to portray the earth as viewed by an observer in space.</p>
</section>
<section id="utm-projection" class="level3">
<h3 class="anchored" data-anchor-id="utm-projection">UTM projection</h3>
<p>Next, we’ll explore a UTM coordinate system (Zone 19 North) and limit the extent to the State of Maine (USA). This will help us visualize the north-south strips of the projection where scale is close to 1 (this location coincides with UTM’s two standard lines).</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-28_43e69cc76af89f7ea14a085fe726d2d4">
<div class="sourceCode cell-code" id="cb35"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">73</span>, <span class="at">ymin =</span> <span class="dv">43</span>)</span>
<span id="cb35-2"><a href="#cb35-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="sc">-</span><span class="dv">65</span>, <span class="at">ymax =</span> <span class="dv">48</span>)</span>
<span id="cb35-3"><a href="#cb35-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb35-4"><a href="#cb35-4" aria-hidden="true" tabindex="-1"></a><span class="fu">r.out</span>(ll, ur, proj.utm19N, <span class="at">bgmap =</span> us) <span class="sc">+</span> <span class="co"># Map with US outline </span></span>
<span id="cb35-5"><a href="#cb35-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>( <span class="at">xintercept =</span> <span class="fu">c</span>(<span class="dv">680000</span>,<span class="dv">320000</span>), <span class="at">linetype =</span> <span class="dv">2</span> ) <span class="co"># Add standard parallels</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-28-1.png" class="img-fluid" width="576"></p>
</div>
</div>
<p>The UTM projection adopts a <a href="https://mgimond.github.io/Spatial/chp09_0.html#cylindrical-projection">secant projection</a> whereby the cylindrical projection <em>contacts</em> the earth at two standard lines (shown as dashed lines in the above figure). As such, the areal scale at the two standard lines is one whereas at the projection’s central meridian (69°W) scale decreases by a small amount (less than 2%). The standard lines are about 360 km from one another. Note that the standard parallels do not follow meridians.</p>
</section>
<section id="plate-carrée-projection" class="level3">
<h3 class="anchored" data-anchor-id="plate-carrée-projection">Plate Carrée projection</h3>
<p>A popular cylindrical coordinate system adopted as a standard projection for geographic data in GIS software like ArcMap and QGIS is the Plate Carrée projection (or a derivative thereof).</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-29_84d9e3a141ee939acac94622a2da2e5f">
<div class="sourceCode cell-code" id="cb36"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">170</span>, <span class="at">ymin =</span> <span class="sc">-</span><span class="dv">85</span>)</span>
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="dv">170</span>, <span class="at">ymax =</span> <span class="dv">80</span>)</span>
<span id="cb36-3"><a href="#cb36-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a><span class="fu">r.out</span>(ll, ur, proj.carree) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-29-1.png" class="img-fluid" width="960"></p>
</div>
</div>
<p>The scale is nearly unity at the equator and increases as one moves poleword.</p>
</section>
<section id="equal-area-projection" class="level3">
<h3 class="anchored" data-anchor-id="equal-area-projection">Equal-area projection</h3>
<p>Now let’s revisit the equal area projection. Let’s generate an areal distortion raster to explore the extent of equal area projection.</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-30_e76c620a54e40733c3753886e40c9de3">
<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">170</span>, <span class="at">ymin =</span> <span class="sc">-</span><span class="dv">85</span>)</span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="dv">170</span>, <span class="at">ymax =</span> <span class="dv">85</span>)</span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-4"><a href="#cb37-4" aria-hidden="true" tabindex="-1"></a><span class="fu">r.out</span>(ll, ur, proj.cea)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-30-1.png" class="img-fluid" width="1056"></p>
</div>
</div>
<p>The map makes it clear that the areal scale remains true (to at least 3 decimal places) for much of the earth’s extent!</p>
</section>
</section>
<section id="combining-indicatrix-with-areal-scale-factor-raster" class="level1">
<h1>Combining indicatrix with areal scale factor raster</h1>
<p>Next, we’ll overlap indicatrix ellipses with areal scale factor rasters. This will allow us to view distortions in shape and length at point locations as well as distortion in area across the entire extent.</p>
<section id="equal-area-projection-1" class="level2">
<h2 class="anchored" data-anchor-id="equal-area-projection-1">Equal-area projection</h2>
<p>We’ll continue with the last projection used (the equal area projection).</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-31_ef410a60e08a787bea86f76c6c3d16d7">
<div class="sourceCode cell-code" id="cb38"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">170</span>, <span class="at">ymin =</span> <span class="sc">-</span><span class="dv">85</span>)</span>
<span id="cb38-2"><a href="#cb38-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="dv">170</span>, <span class="at">ymax =</span> <span class="dv">85</span>)</span>
<span id="cb38-3"><a href="#cb38-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-4"><a href="#cb38-4" aria-hidden="true" tabindex="-1"></a>out.rast <span class="ot"><-</span> <span class="fu">r.out</span>(ll, ur, proj.cea)</span>
<span id="cb38-5"><a href="#cb38-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-6"><a href="#cb38-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate Tissot indicatrix</span></span>
<span id="cb38-7"><a href="#cb38-7" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">80</span>, <span class="dv">80</span>, <span class="at">by =</span> 20L)</span>
<span id="cb38-8"><a href="#cb38-8" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">150</span>, <span class="dv">150</span>, <span class="at">by =</span> 35L)</span>
<span id="cb38-9"><a href="#cb38-9" aria-hidden="true" tabindex="-1"></a>tsf <span class="ot"><-</span> <span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.cea, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon, <span class="at">plot =</span> <span class="cn">FALSE</span>)</span>
<span id="cb38-10"><a href="#cb38-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-11"><a href="#cb38-11" aria-hidden="true" tabindex="-1"></a><span class="co"># Add indicatrix to map</span></span>
<span id="cb38-12"><a href="#cb38-12" aria-hidden="true" tabindex="-1"></a>out.rast <span class="sc">+</span> </span>
<span id="cb38-13"><a href="#cb38-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>base, <span class="at">fill =</span> <span class="cn">NA</span>, <span class="at">col =</span> <span class="st">"grey50"</span>) <span class="sc">+</span></span>
<span id="cb38-14"><a href="#cb38-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>ind, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb38-15"><a href="#cb38-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>mina, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb38-16"><a href="#cb38-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>maja, <span class="at">col=</span><span class="st">"green"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb38-17"><a href="#cb38-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>lam, <span class="at">col=</span><span class="st">"grey50"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb38-18"><a href="#cb38-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>phi, <span class="at">col=</span><span class="st">"grey80"</span>, <span class="at">fill =</span> <span class="cn">NA</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-31-1.png" class="img-fluid" width="1056"></p>
</div>
</div>
<p>While the area scale remains true across the map’s extent, its shape clearly does not. Distortion of north-south and east-west scales is needed to ensure that the area is preserved near the poles.</p>
</section>
<section id="gnomonic-projection" class="level2">
<h2 class="anchored" data-anchor-id="gnomonic-projection">Gnomonic projection</h2>
<p>One interesting projection is the gnomonic projection. This projection is unique in that great circles (shortest distance on an ellipsoid) from the center of the projection map to a straight line. In other words, the shortest distance between to points on this projected map is the true great circle distance. The following map is that of a gnomonic projection centered at 30° North and 100° West.</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-32_e84d2100d69fe0f1e255870e2c19ce99">
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">130</span>, <span class="at">ymin =</span> <span class="dv">0</span>)</span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="sc">-</span><span class="dv">45</span>, <span class="at">ymax =</span> <span class="dv">65</span>)</span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate raster output</span></span>
<span id="cb39-5"><a href="#cb39-5" aria-hidden="true" tabindex="-1"></a>out.rast <span class="ot"><-</span> <span class="fu">r.out</span>(ll, ur, proj.gnom)</span>
<span id="cb39-6"><a href="#cb39-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-7"><a href="#cb39-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate Tissot indicatrix</span></span>
<span id="cb39-8"><a href="#cb39-8" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="dv">5</span>, <span class="dv">65</span>, <span class="at">by =</span> 10L)</span>
<span id="cb39-9"><a href="#cb39-9" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">120</span>, <span class="sc">-</span><span class="dv">70</span>, <span class="at">by =</span> 20L)</span>
<span id="cb39-10"><a href="#cb39-10" aria-hidden="true" tabindex="-1"></a>tsf <span class="ot"><-</span> <span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.gnom, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon, <span class="at">plot =</span> <span class="cn">FALSE</span>)</span>
<span id="cb39-11"><a href="#cb39-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-12"><a href="#cb39-12" aria-hidden="true" tabindex="-1"></a><span class="co"># Add indicatrix to map</span></span>
<span id="cb39-13"><a href="#cb39-13" aria-hidden="true" tabindex="-1"></a>out.rast <span class="sc">+</span> </span>
<span id="cb39-14"><a href="#cb39-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>base, <span class="at">fill =</span> <span class="cn">NA</span>, <span class="at">col =</span> <span class="st">"grey50"</span>) <span class="sc">+</span></span>
<span id="cb39-15"><a href="#cb39-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>ind, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb39-16"><a href="#cb39-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>mina, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb39-17"><a href="#cb39-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>maja, <span class="at">col=</span><span class="st">"green"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb39-18"><a href="#cb39-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>lam, <span class="at">col=</span><span class="st">"grey50"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb39-19"><a href="#cb39-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>phi, <span class="at">col=</span><span class="st">"grey80"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb39-20"><a href="#cb39-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_sf</span>(<span class="at">xlim =</span> <span class="fu">st_bbox</span>(tsf<span class="sc">$</span>base)[<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>)], </span>
<span id="cb39-21"><a href="#cb39-21" aria-hidden="true" tabindex="-1"></a> <span class="at">ylim =</span> <span class="fu">st_bbox</span>(tsf<span class="sc">$</span>base)[<span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">4</span>)])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-32-1.png" class="img-fluid" width="576"></p>
</div>
</div>
</section>
<section id="equidistance-conical-projection" class="level2">
<h2 class="anchored" data-anchor-id="equidistance-conical-projection">Equidistance conical projection</h2>
<p>If distance is an important spatial property for your analysis, you can adopt an equidistant projection.</p>
<div class="cell" data-hash="index_cache/html/unnamed-chunk-33_3641b096171443c19f94cac09be7ca33">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>ll <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmin =</span> <span class="sc">-</span><span class="dv">130</span>, <span class="at">ymin =</span> <span class="dv">20</span>)</span>
<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a>ur <span class="ot"><-</span> <span class="fu">c</span>(<span class="at">xmax =</span> <span class="sc">-</span><span class="dv">60</span>, <span class="at">ymax =</span> <span class="dv">60</span>)</span>
<span id="cb40-3"><a href="#cb40-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-4"><a href="#cb40-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate raster output</span></span>
<span id="cb40-5"><a href="#cb40-5" aria-hidden="true" tabindex="-1"></a>out.rast <span class="ot"><-</span> <span class="fu">r.out</span>(ll, ur, proj.eqdc)</span>
<span id="cb40-6"><a href="#cb40-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-7"><a href="#cb40-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate Tissot indicatrix</span></span>
<span id="cb40-8"><a href="#cb40-8" aria-hidden="true" tabindex="-1"></a>lat <span class="ot"><-</span> <span class="fu">seq</span>(<span class="dv">30</span>, <span class="dv">50</span>, <span class="at">by=</span>10L)</span>
<span id="cb40-9"><a href="#cb40-9" aria-hidden="true" tabindex="-1"></a>lon <span class="ot"><-</span> <span class="fu">seq</span>(<span class="sc">-</span><span class="dv">120</span>, <span class="sc">-</span><span class="dv">70</span>, <span class="at">by=</span>20L)</span>
<span id="cb40-10"><a href="#cb40-10" aria-hidden="true" tabindex="-1"></a>tsf <span class="ot"><-</span> <span class="fu">ti.out</span>(<span class="at">proj.out =</span> proj.eqdc, <span class="at">lat =</span> lat, <span class="at">lon =</span> lon, <span class="at">plot =</span> <span class="cn">FALSE</span>)</span>
<span id="cb40-11"><a href="#cb40-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-12"><a href="#cb40-12" aria-hidden="true" tabindex="-1"></a>out.rast <span class="sc">+</span> </span>
<span id="cb40-13"><a href="#cb40-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>base, <span class="at">fill =</span> <span class="cn">NA</span>, <span class="at">col =</span> <span class="st">"grey50"</span>) <span class="sc">+</span></span>
<span id="cb40-14"><a href="#cb40-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>ind, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb40-15"><a href="#cb40-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>mina, <span class="at">col=</span><span class="st">"red"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb40-16"><a href="#cb40-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>maja, <span class="at">col=</span><span class="st">"green"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb40-17"><a href="#cb40-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>lam, <span class="at">col=</span><span class="st">"grey50"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb40-18"><a href="#cb40-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_sf</span>(<span class="at">data =</span> tsf<span class="sc">$</span>phi, <span class="at">col=</span><span class="st">"grey80"</span>, <span class="at">fill =</span> <span class="cn">NA</span>) <span class="sc">+</span></span>
<span id="cb40-19"><a href="#cb40-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_sf</span>(<span class="at">xlim =</span> <span class="fu">st_bbox</span>(tsf<span class="sc">$</span>base)[<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>)], </span>
<span id="cb40-20"><a href="#cb40-20" aria-hidden="true" tabindex="-1"></a> <span class="at">ylim =</span> <span class="fu">st_bbox</span>(tsf<span class="sc">$</span>base)[<span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">4</span>)])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-33-1.png" class="img-fluid" width="1056"></p>
</div>
</div>
<p>This projection adopts a secant case in that two standard parallels (30°N and 45°N) are used to define where the projection makes contact with the underlying spheroid. As such, minimum scale distortion will occur along these standards.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="dv">30</span>, <span class="at">proj.out =</span> proj.eqdc)</span>
<span id="cb41-2"><a href="#cb41-2" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="dv">45</span>, <span class="at">proj.out =</span> proj.eqdc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-34-1.png" class="img-fluid" width="1056"></p>
</div>
</div>
<p>Distortion increases north or south of these parallels. For example:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb42"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="dv">40</span>, <span class="at">proj.out =</span> proj.eqdc)</span>
<span id="cb42-2"><a href="#cb42-2" aria-hidden="true" tabindex="-1"></a>out <span class="ot"><-</span> <span class="fu">local_TI</span>(<span class="at">long =</span> <span class="sc">-</span><span class="fl">69.5</span>, <span class="at">lat =</span> <span class="dv">50</span>, <span class="at">proj.out =</span> proj.eqdc)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="index_files/figure-html/unnamed-chunk-35-1.png" class="img-fluid" width="1056"></p>
</div>
</div>
<p>Overall, this coordinate system does a decent job in limiting distance errors to 2% within the contiguous 48 states.</p>
<hr>
<p><em>Code in this tutorial was created with the following external libraries</em></p>
<table class="table">
<tbody>
<tr class="odd">
<td style="text-align: left;">GEOS</td>
<td style="text-align: left;">3.9.3</td>
</tr>
<tr class="even">
<td style="text-align: left;">GDAL</td>
<td style="text-align: left;">3.5.2</td>
</tr>
<tr class="odd">
<td style="text-align: left;">proj.4</td>
<td style="text-align: left;">8.2.1</td>
</tr>
<tr class="even">
<td style="text-align: left;">GDAL_with_GEOS</td>
<td style="text-align: left;">true</td>
</tr>
<tr class="odd">
<td style="text-align: left;">USE_PROJ_H</td>
<td style="text-align: left;">true</td>
</tr>
<tr class="even">
<td style="text-align: left;">PROJ</td>
<td style="text-align: left;">8.2.1</td>
</tr>
</tbody>
</table>
<hr>
<p><img src="http://i.creativecommons.org/l/by-sa/4.0/88x31.png" class="img-fluid" alt="Copyleft"> Manny Gimond, 2023</p>
</section>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
setTimeout(function() {
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const cites = ref.parentNode.getAttribute('data-cites').split(' ');
tippyHover(ref, function() {
var popup = window.document.createElement('div');
cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
});
</script>
</div> <!-- /content -->
</body></html>