-
Notifications
You must be signed in to change notification settings - Fork 1
/
gis_lecture2.html
2132 lines (1984 loc) · 64.2 KB
/
gis_lecture2.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 lang="en">
<head>
<meta charset="utf-8">
<!-- For Google search results -->
<title>ArcGIS for Economics: Lecture 2</title>
<meta name="description" content="ArcGIS's Spatial Join for economics researchers">
<meta name="author" content="Masayuki Kudamatsu">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<!-- Activate Reveal.js -->
<link rel="stylesheet" href="css/reveal.css">
<!-- Define the theme -->
<link rel="stylesheet" href="css/theme/white4me.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/tomorrow.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--Add support for earlier versions of Internet Explorer -->
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<!-- To activate the CSS framework of Reveal.js -->
<div class="reveal">
<!-- To reconfigure an HTML5 <section> element as a slide using CSS. -->
<div class="slides">
<!-- Slide contents start here -->
<!-- My own slide templates -->
<section id="title">
<h3 style="color:slategrey">
Causal Inference with Spatial Data
</h3>
<p style="color:slategrey">
(ArcGIS 10 for Economics Research)
</p>
<h3>
Lecture 2
</h3>
<h2>
Spatial Join
</h2>
<br>
<code><a href="http://mkudamatsu.github.io/gis_lecture2.html">mkudamatsu.github.io/gis_lecture2.html</a></code>
<br>
<p>Masayuki Kudamatsu</p>
<p>12 October, 2018</p>
<br>
<p>
<small>Press SPACE to proceed. </small>
<br>
<small>To go back to the previous slide, press SHIFT+SPACE. </small>
</p>
</section>
<section id="what_is_spatial_join" data-transition="slide-in fade-out" style="text-align: left;">
<h3>
What is Spatial Join?
</h3>
<p>
Match <strong>features</strong> from two vector datasets by location
</p>
<ul>
<li>
No need of common keys (e.g. district code) to match data
</li>
<li class="fragment" data-fragment-index="2">
Allow you to match administrative data with <strong>natural environment data</strong>
</li>
</ul>
</section>
<section id="biome" data-transition="fade-in fade-out" style="text-align: left;">
<h4>
Example: <a href="https://www.worldwildlife.org/publications/terrestrial-ecoregions-of-the-world">Terrestrial Ecoregions</a>
</h4>
<img src="gis_lecture2/biome.png" style="border: none; background: none; box-shadow:none; width: 600px;">
<p>
<a href="http://doi.org/10.1093/qje/qjx030">Henderson et al. (2018)</a> find these ecoregions predict where economic activities take place
</p>
<p class="fragment" data-fragment-index="2">
But we cannot easily match this data to administrative areas without spatial join
</p>
</section>
<section id="benefits" data-transition="fade-in slide-out" style="text-align: left;">
<h3>
Spatial Join and Weather Data
</h3>
<p>
Weather data: increasingly popular among economists
</p>
<ul>
<li>
Interest in climate change (<a href="http://doi.org/10.1257/jel.52.3.740" target="_blank">Dell et al. (2014)</a> for a survey)
</li>
<li>
Since weather is exogenous, causality can be established
</li>
</ul>
<p class="fragment" data-fragment-index="2">
But <strong>grid cells</strong> are the units of observation in weather data
</p>
<div class="fragment" data-fragment-index="3" style="display: flex; align-items: flex-start; justify-content: space-between;">
<img src="gis_lecture2/gridcells.png" style="border: none; background: none; box-shadow:none; width: 300px;">
<div style="margin-left: 10px;">
<p>
Evenly spaced meridians and parallels divide the earth into <strong>grid cells</strong>
</p>
<p><small>(Image source: ArcGIS Help "<a href="http://desktop.arcgis.com/en/arcmap/latest/map/page-layouts/what-are-grids-and-graticules-.htm" target="_blank">What are grids and graticules?</a>")</small></p>
<p class="fragment" data-fragment-index="4">
$\Rightarrow$ Spatial Join matches grid cells with socio-economic units
</p>
</div>
</div>
</section>
<section id="road_map" style="text-align: left;">
<h3>
Today's road map
</h3>
<p>
1. Alsan (2015)
</p>
<p>
2. Replicate Alsan (2015)
</p>
<p>
3. Introduction to Python for ArcGIS
</p>
</section>
<!-- SECTION 2 -->
<section>
<section id="section2">
<h1>
1. <a href="http://dx.doi.org/10.1257/aer.20130604" target="_blank">Alsan (2015)</a>
</h1>
<img src="gis_lecture2/Tsetsefly.jpg" style="border: none; background: none; box-shadow:none; width: 400px;">
</section>
<section id="rq2" style="text-align: left;">
<h3>Research Question</h3>
<p>
Did Tsetse flies cause Africa's poverty?
</p>
<p class="fragment" data-fragment-index="2">
Important?
</p>
<ul>
<li class="fragment" data-fragment-index="3">
Tsetse flies, found only in Africa, kill livestock
</li>
<li class="fragment" data-fragment-index="4">
Believed to be a historical cause of Africa's low agricultural productivity & high transportation cost
</li>
<li class="fragment" data-fragment-index="5">
Path dependence may explain Africa's poverty today
</li>
</ul>
<p class="fragment" data-fragment-index="2">
Original?
</p>
<ul>
<li class="fragment" data-fragment-index="6">
No systematic evidence on the impact of Tsetse flies
</li>
<li class="fragment" data-fragment-index="7">
Find Tsetse flies prevented political centralization
</li>
</ul>
<p class="fragment" data-fragment-index="2">
Feasible?
</p>
</section>
<section id="data2a" data-transition="slide-in fade-out" style="text-align: left;">
<h3>Data Sources</h3>
<p>
Ethnographic Atlas + <a href="../gis_lecture1.html#/oldmap2b" target="_blank">Murdock (1959)'s map</a>
</p>
<ul>
<li>
Pre-colonial data on use of domesticated animals, presence of intensive agriculture, political centralization
</li>
</ul>
<p class="fragment" data-fragment-index="2">
Weather at 2°x2° grid cells in 1871 from <a href="https://www.esrl.noaa.gov/psd/data/20thC_Rean/" target="_blank">20th Century Reanalysis Project</a>
</p>
<ul class="fragment" data-fragment-index="2">
<li>
Mean temperature
</li>
<li>
Mean humidity
</li>
</ul>
</section>
<section id="data2b" data-transition="fade-in fade-out" style="text-align: left;">
<h3>Climate factors of Tsetse Survival</h3>
<p style="text-align: right;">(Figure 2 of Alsan 2015)</p>
<img src="gis_lecture2/alsan2015figure2a.png" style="border: none; background: none; box-shadow:none; width: 400px;">
<img src="gis_lecture2/alsan2015figure2b.png" style="border: none; background: none; box-shadow:none; width: 400px;">
<p class="fragment" data-fragment-index="2">
Feed temperature and humidity into the these curves
</p>
<p class="fragment" data-fragment-index="2">
$\Rightarrow$ Tsetse Suitability Index (steady-state population)
</p>
</section>
<section id="data2c" data-transition="fade-in slide-out" style="text-align: left;">
<div style="display: flex; align-items: flex-start;">
<div class="">
<h4>Tsetse Suitability</h4>
<img src="gis_lecture2/alsan2015figure3a.png" style="border: none; background: none; box-shadow:none; width: 400px;">
</div>
<div style="align-self: center;" class="fragment" data-fragment-index="1">
<h2>+</h2>
</div>
<div class="fragment" data-fragment-index="1">
<h4>Ethnic homelands</h4>
<img src="gis_lecture2/alsan2015figure5a.png" style="border: none; background: none; box-shadow:none; width: 420px;">
</div>
</div>
<p style="color:slategrey" class="fragment" data-fragment-index="2">
We will learn how to match these two data
</p>
</section>
<section id="equation2" style="text-align: left">
<h3>
Empirical specification
</h3>
<p>
<!-- Case by Case -->
\begin{align*}
Y_j =
\alpha + \delta TSI_j + \boldsymbol{X}'_{j}\boldsymbol{\omega} + \varepsilon_{j}
\end{align*}
</p>
<table border="0" width="100%">
<tr>
<td style="text-align: right">$Y_j$</td>
<td>Precolonial outcome for ethnic group $j$</td>
</tr>
<tr>
<td style="text-align: right">$TSI_j$</td>
<td>Tsetse fly suitability index</td>
</tr>
<tr>
<td style="text-align: right">$\boldsymbol{X}_j$</td>
<td>Controls (incl.\ temperature, humidity in 1871)</td>
</tr>
</table>
</section>
<section id="result2" >
<h4>
Main Results
</h4>
<p>
<img src="gis_lecture2/alsan_table1.png" style="border: none; background: none; box-shadow:none; width: 750px;">
<small>(Table 1 of Alsan 2015)</small>
</p>
</section>
</section>
<section id="preparation1" data-transition="fade-out slide-in" style="text-align: left;">
<h3>
Prepare for the rest of this lecture
</h3>
<ol>
<li>
<a href="https://www.dropbox.com/s/xibuez209w6swft/Lecture2.zip?dl=1" target="_blank">Download the zipped dataset for lecture 2</a>
</li>
<ul>
<li>Save it in Desktop</li>
</ul>
<li>
To unzip, right-click it and choose <span style="background-color: Gainsboro">7-Zip > Extract to "Lecture2\"</span>
</li>
<li>
Launch ArcMap 10 (it takes time)
</li>
</ol>
</section>
<section>
<section id="section5">
<h1>
2. Replicate Alsan (2015)
</h1>
</section>
<section id="what_we_learn" data-transition="fade-out slide-in" style="text-align: left;">
<h3>
we will learn how to:
</h3>
<p>1. Use the Spatial Join tool <span style="color:slategrey" >(Exercise 2)</span></p>
<p>2. Export attribute tables to Stata <span style="color:slategrey" >(Exercise 3)</span></p>
<p>3. Create <strong>grid cell polygons</strong> <span style="color:slategrey" >(Exercise 1)</span></p>
</section>
<section id="graticule" data-transition="fade-out fade-in" style="text-align: left;">
<h3>
Why grid cell polygons?
</h3>
<p>
In natural science data (e.g. weather data), <br>the unit of observations is often a grid cell.
<ul>
<li>
Partly because they derive data from satellite images
</li>
</ul>
</p>
<p class="fragment" data-fragment-index="2">
Examples:
</p>
<ul class="fragment" data-fragment-index="2" style="margin-left: 60px;">
<li>
<a href="https://www.esrl.noaa.gov/psd/data/gridded/data.gpcp.html" target="_blank">GCPC</a>: time-series of precipitation (2.5-deg)
<ul>
<li>used by <a href="http://www.jstor.org/stable/10.1086/421174" target="_blank">Miguel et al. (2004)</a></li>
</ul>
</li>
<li>
<a href="http://www.worldclim.org/" target="_blank">WorldClim</a>: cross-section of monthly weather (30-sec)
<ul>
<li>used by <a href="http://dx.doi.org/10.1257/aer.99.2.198" target="_blank">Dell, Jones, & Olken (2009)</a></li>
</ul>
</li>
<li>
<a href="http://cersat.ifremer.fr/" target="_blank">CERSAT</a>: wind speed and direction in oceans (1-deg)
<ul>
<li>used by <a href="http://dx.doi.org/10.1257/aer.20140832" target="_blank">Pascali (2017)</a></li>
</ul>
</li>
</ul>
<p class="fragment" data-fragment-index="3">
Grid cell polygons help merge these data with other data
</p>
</section>
<section id="ex1a" data-transition="fade-out fade-in" style="text-align: left;">
<h4>
Exercise #1: Overview
</h4>
<h3>
Create 20th-century Reanalysis data grid cell polygons
</h3>
<p>
We will use 3 geo-processing tools for this exercise:
</p>
<ol>
<li>
Create Fishnet
</li>
<li>
Define Projection (Data Management)
</li>
<li>
Add Geometry Attributes
</li>
</ol>
<p class="fragment" data-fragment-index="2" >
As in Lecture 1, we use these tools in Model Builder.
</p>
<ol class="fragment" data-fragment-index="2" >
<li>
<a href="../gis_lecture1.html#/modelbuilder1" target="_blank">Create a Model</a>
</li>
<li>
<a href="../gis_lecture1.html#/modelbuilder3" target="_blank">Save it</a> as <code>code/lecture2.tbx/exercises1-3</code>
</li>
</ol>
</section>
<section id="ex1b" data-transition="slide-out fade-in" style="text-align: left;">
<h4>
Exercise #1: Overview (cont.)
</h4>
<h3>
20th-century Reanalysis data
</h3>
<p>
Spatial resolution: 2° x 2°
</p>
<p>
Africa: roughly spans within
</p>
<ul>
<li>40° S to 40° N</li>
<li>20° W to 60° E</li>
</ul>
<p class="fragment" data-fragment-index="2" >
$\Rightarrow$ Create square polygons whose centroid is from (-20°, -40°) to (60°, 40°) at the interval of 2°
</p>
</section>
<section id="fishnet1" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #1: Step 1
</h4>
<h3>
Create Fishnet
</h3>
<p>
<strong>Output Feature Class</strong>: <code>...\Lecture2\temporary\fishnet.shp</code>
</p>
<ul>
<li>
Save all intermediate outputs in the <code>temporary/</code> folder
</li>
</ul>
<p>
<strong>Fishnet Origin Coordinate</strong>
</p>
<p style="margin-left: 60px;">
<strong>X Coordinate</strong>: -21
</p>
<p style="margin-left: 60px;">
<strong>Y Coordinate</strong>: -41
</p>
<p>
$\Rightarrow$ Bottom-left polygon's centroid will be (-20°, -40°)
</p>
</section>
<section id="fishnet2" data-transition="fade" style="text-align: left;">
<h3>
Create Fishnet (cont.)
</h3>
<p>
<strong>Y-Axis Coordinate</strong>
</p>
<p style="margin-left: 60px;">
<strong>X Coordinate</strong>: -21
</p>
<p style="margin-left: 60px;">
<strong>Y Coordinate</strong>: -10 (or any value other than -41)
</p>
<p>
$\Rightarrow$ Y-Axis will be perpendicular to the horizontal X-Axis
</p>
<p>
<strong>Number of Rows</strong>: 41
</p>
<ul>
<li>
(40-(-40))/2 + 1 = 41
</li>
</ul>
<p>
<strong>Number of Columns</strong>: 41
</p>
<ul>
<li>
(60-(-20))/2 + 1 = 41
</li>
</ul>
</section>
<section id="fishnet3" data-transition="slide-out fade-in" style="text-align: left;">
<h3>
Create Fishnet (cont.)
</h3>
<p>
Uncheck "<strong>Create Label Points</strong>"
</p>
<ul>
<li>
Label points: unnecessary for our purpose
</li>
<li>
Model Builder will still show label points as an output from Create Fishnet. This is a bug.
</li>
</ul>
<p>
<strong>Geometry Type</strong>: POLYGON
</p>
<ul>
<li>
By default, this option is set as POLYLINE. Make sure to change it.
</li>
</ul>
</section>
<section id="ex1ba" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #1: Step 2
</h4>
<p>
The Create Fishnet tool doesn't assign any coordination system to the output file
</p>
<p class="fragment" data-fragment-index="2" >
Ethnographic Atlas data uses geographic coordinate system
</p>
<p class="fragment" data-fragment-index="3" >
$\Rightarrow$ Assign WGS 1984
</p>
<p class="fragment" data-fragment-index="4" >
How? We already learned this in <a href="../gis_lecture1.html#/ex6a" target="_blank">Lecture 1 Exercise 6</a>.
</p>
</section>
<section id="define_projection" data-transition="slide-out fade-in" style="text-align: left;">
<h4>
Exercise #1: Step 2 (cont.)
</h4>
<h3>
Define Projection (Data Management)
</h3>
<p>
<strong>Input Dataset or Feature Class</strong>: fishnet.shp
</p>
<ul>
<li>
Use the drop down menu to choose the output from Create Fishnet
</li>
</ul>
<p>
<strong>Coordinate System</strong>: GCS_WGS_1984
</p>
<ul style="margin-left: 60px;">
<li>
Click <img src="gis_lecture2/coordinate.png" style="border: none; background: none; box-shadow:none; width:40px; vertical-align: middle;">
</li>
<li>
Navigate to Geographic Coordinate Systems > World > WGS 1984
</li>
</ul>
</section>
<section id="ex1c" style="text-align: left;">
<h4>
Exercise #1 (cont.)
</h4>
<p>
Now <em>save and</em> run the Model.
</p>
<p>
Browse the output.
</p>
<p>
Overlay the Ethnographic Atlas data
</p>
<ul>
<li>
<code>.../Lecture2/input/tribemap.shp</code>
</li>
</ul>
<p>
20th Century Reanalysis data cell polygons should cover the whole mainland Africa.
</p>
</section>
<section id="ex1d" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #1: Step 3
</h4>
<p>
Browse the attribute table of the output (cf. <a href="../gis_lecture1.html#/attribute_table" target="_blank">Lecture 1</a>)
</p>
<p>
We don't see centroid coordinates to match with weather data...
</p>
<p class="fragment" data-fragment-index="2">
$\Rightarrow$ Use the Add Geometry Attributes tool
</p>
</section>
<section id="f2p" data-transition="fade-in slide-out" style="text-align: left;">
<h4>
Exercise #1: Step 3 (cont.)
</h4>
<h3>
Add Geometry Attributes
</h3>
<p>
To add the centroid coordinate values in attribute table
</p>
<p>
<strong>Input Features</strong>: <code>fishnet.shp (2)</code>
</p>
<ul>
<li>
This is the output from Define Projection
</li>
<li>
Don't choose <code>fishnet.shp</code> (which is the output from Create Fishnet)
</li>
</ul>
<p>
<strong>Geometry Properties</strong>: check CENTROID
</p>
<ul>
<li>
The CENTROID_INSIDE is for hollow polygons
</li>
</ul>
<p>
Note: this tool overwrites the input file
</p>
</section>
<section id="ex1e" style="text-align: left;">
<h4>
Exercise #1 (cont.)
</h4>
<p>
Now <em>save and</em> run the Model.
</p>
<p>
Browse the output and its attribute table.
</p>
<p>
Is everything as expected?
</p>
</section>
<section id="ex2a1" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #2: Overview
</h4>
<h3>
Merge ethnic homelands <br>with 20th Century Reanalysis cells
</h3>
<p>
Ethnic homelands: polygons
</p>
<p>
How to match polygons with polygons?
</p>
<ul class="fragment" data-fragment-index="2" >
<li>
One polygon can overlap with several polygons
</li>
<li>
Which one to pick? How to aggregate them?
</li>
</ul>
<p class="fragment" data-fragment-index="3" >
One way to go: match <strong>polygon centroids</strong> with polygons
</p>
</section>
<section id="centroid" data-transition="fade" style="text-align: left;">
<h4>
Exercise #2: Overview (cont.)
</h4>
<h3>
Polygon centroid
</h3>
<p>
Mean position of all points on the polygon boundary
</p>
<img style="border: none;"src="gis_lecture2/centroids.png" alt="">
<p>
<small>(<a href="https://en.wikipedia.org/wiki/Centroid" target="_blank">Image source</a>)</small>
</p>
<p>
$\Rightarrow$ Can be matched with a single weather data grid cell
</p>
</section>
<section id="ex2a2" data-transition="fade-in slide-out" style="text-align: left;">
<h4>
Exercise #2: Overview (cont.)
</h4>
<p>
1. Create ethnic homeland centroid point features
</p>
<ul class="fragment" data-fragment-index="2">
<li>
We have XY data in the attribute table of the ethnic homeland polygon (<code>.../input/tribalmap.shp</code>)
</li>
<li class="fragment" data-fragment-index="3">
Which geo-processing tools should we use?
</li>
<ul class="fragment" data-fragment-index="3">
<li>hint: <a href="../gis_lecture1.html#/ex3a" target="_blank">Lecture 1 Exercise 3</a></li>
</ul>
</ul>
<p>
2. Use Spatial Join to match ethnic homeland centroids with 20th Century Reanalysis grid cells
</p>
<p class="fragment" data-fragment-index="4">
We now add these processes to the Model for Excercise 1
</p>
</section>
<section id="ex2b" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #2: Step 1
</h4>
<h3>
Make XY Event Layer
</h3>
<p>
<strong>XY Table</strong>: <code>...\input\tribalmap.shp</code>
</p>
<ul>
<li>Note this tool can be used for shapefiles</li>
</ul>
<p>
<strong>X Field</strong>: <code>tribelon</code>
</p>
<p>
<strong>Y Field</strong>: <code>tribelat</code>
</p>
<ul>
<li>These two variables were most likely to be created with the Add Geometry Attributes tool (cf. <a href="../gis_lecture2.html#ex1d" target="_blank">Exercise 1 Step 3</a>)</li>
</ul>
<p>
<strong>Spatial Reference</strong>: GCS_WGS_1984
</p>
<p>
Leave the other options as they are.
</p>
</section>
<section id="ex2c" data-transition="fade" style="text-align: left;">
<h4>
Exercise #2: Step 1 (cont.)
</h4>
<h3>
Copy Features
</h3>
<p>
<strong>Input Features</strong>: tribalmap_Layer
</p>
<ul>
<li>
The output from Make XY Event Layer:
</li>
<li>
Use the drop down menu
</li>
</ul>
<p>
<strong>Output Feature Class</strong>: <code>...\temporary\ethno_centroids.shp</code>
</p>
</section>
<section id="ex2d" data-transition="slide-out fade-in" style="text-align: left;">
<h4>
Exercise #2 (cont.)
</h4>
<p>
Now <em>save and</em> run the Model.
</p>
<p>
Browse the output and its attribute table.
</p>
<p>
Is everything as expected?
</p>
</section>
<section id="ex2e" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #2: Step 2
</h4>
<h3>
Spatial Join
</h3>
<p>
<strong>Target Feature Class</strong>: ethno_centroids.shp
</p>
<ul>
<li>
The output from Copy Features
</li>
</ul>
<p>
<strong>Join Features</strong>: fishnet.shp
</p>
<ul>
<li>
The output from Add Geometry Attributes (in Exercise 1)
</li>
</ul>
<p>
<strong>Output Feature Class</strong>: <code>...\temporary\ethno_centroids_with_20cr2.shp</code>
</p>
</section>
<section id="ex2f" data-transition="slide-out fade-in" style="text-align: left;">
<h3>
Spatial Join (cont.)
</h3>
<p>
<strong>Join Operation</strong>: JOIN_ONE_TO_ONE
</p>
<ul>
<li>
We match each ethnic group with one weather data cell
</li>
</ul>
<p>
Check "<strong>Keep All Target Features</strong>"
</p>
<ul>
<li>
We want to know which ethnic groups aren't matched with weather data, if any
</li>
</ul>
<p>
<strong>Field Map of Join Features</strong>: leave as it is
</p>
<p>
<strong>Match Option</strong>: INTERSECT
</p>
<ul>
<li>
Each ethnic group's centroid should match with the weather cell that intersects it
</li>
</ul>
</section>
<section id="ex2g" style="text-align: left;">
<h4>
Exercise #2 (we're done!)
</h4>
<p>
Now <em>save and</em> run the Model.
</p>
<ul>
<li>
I deliberately repeat this slide so you will form the habit of saving the Model before running it.
</li>
</ul>
<p>
Browse the output and its attribute table.
</p>
<p>
Is everything as expected?
</p>
</section>
<!-- <section id="why_polygon" style="text-align: left;">
<h3>
Why cell polygons for weather data?
</h3>
<p>
If we match ethnic groups with weather data cell centroids...
</p>
<ul>
<li>
It is feasible with Spatial Join tool (CLOSEST as the Match Option)
</li>
</ul>
<p>
... it'll take <span style="font-size: 1.5em">a lot</span> of time
</p>
<ul>
<li>
Each of over <span style="font-size: 1.5em">843</span> ethnic groups will be matched with the nearest among <span style="font-size: 1.5em">1681</span> weather data cells</li>
</ul>
<p>
Much quicker to match points with polygons by INTERSECT
</p>
</section> -->
<section id="export0" data-transition="slide-in fade-out" style="text-align: left;">
<h3>
Export to Stata
</h3>
<p>
Now we want to export the attribute table of <code>ethno_centroids_with_20cr2.shp</code> to Stata
</p>
<ul>
<li>
Then we can merge Ethnographic Atlas data with 20th Century Reanalysis data
</li>
</ul>
<p>
3 ways to export the attribute table to the format readable by Stata
</p>
<ul>
<li>
Table To Excel
</li>
<li>
Export Feature Attribute to ASCII
</li>
<li>
shp2dta (a STATA ado)
</li>
</ul>
</section>
<section id="export1" data-transition="fade-in fade-out" style="text-align: left;">
<h4>
Export to Stata (cont.)
</h4>
<h3>
Table To Excel
</h3>
<p>
Converts the attribute table into an Excel file
</p>
<p>
Then use <a href="https://www.stata.com/manuals/dimportexcel.pdf" target="_blank">import excel</a> in Stata
</p>
<p>
But Excel cannot handle more than 65535 rows...
</p>
</section>
<section id="export2" data-transition="fade-in fade-out" style="text-align: left;">
<h4>
Export to Stata (cont.)
</h4>
<h3>
Export Feature Attribute to ASCII
</h3>
<p>
Converts the attribute table into an ASCII text file
</p>
<p>
Then use <a href="https://www.stata.com/manuals/dimportdelimited.pdf" target="_blank">import delimited</a> in Stata
</p>
<p>
This tool will automatically add centroid coordinates to the output ASCII file
</p>
<p>
Unlike Table To Excel, must specify which fields to export
</p>
</section>
<section id="export3" data-transition="fade-in slide-out" style="text-align: left;">
<h4>
Export to Stata (cont.)
</h4>
<h3>
<a href="http://fmwww.bc.edu/RePEc/bocode/s/shp2dta.html" target="_blank">shp2dta</a>
</h3>
<p>
This Stata ado directly reads a shapefile's attribute table
</p>
<p>
But it works <em>only with polygons</em>
</p>
</section>
<section id="ex3a1" data-transition="slide-in fade-out" style="text-align: left;">
<h4>
Exercise #3
</h4>
<h3>
Export Attribute Table
</h3>
<p>
1. Table To Excel
</p>
<ul>
<li>
<strong>Input Table</strong> (use drop-down menu): ethno_centroids_with_20cr2.shp
</li>
<li>
<strong>Output Excel File</strong>: <code>...\output\ethno_centroids_with_20cr2.xls</code>
</li>
</ul>
</section>
<section id="ex3a2" data-transition="fade -in fade-out" style="text-align: left;">
<h4>
Exercise #3
</h4>
<h3>
Export Attribute Table (cont.)
</h3>
<p>
2. Export Feature Attribute to ASCII
</p>