-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx2.Rmd
955 lines (693 loc) · 77.9 KB
/
Ex2.Rmd
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
---
title: "Exercise 2: Getting to know... <br><small>Geographic Information Systems 1 Lab</small></br>"
author: "GEOG 3150"
output:
html_notebook:
df_print: paged
rows.print: 10
theme: cosmo
highlight: breezedark
number_sections: yes
toc: yes
toc_float:
collapsed: no
smooth_scroll: yes
pdf_document: default
html_document:
toc: yes
df_print: paged
editor_options:
chunk_output_type: inline
mode: gfm
---
```{=html}
<style type="text/css">
h1.title {
font-size: 40px;
font-family: "Times New Roman", Times, serif;
color: DarkBlue;
text-align: center;
}
h4.author {
font-size: 20px;
font-family: "Times New Roman", Times, serif;
color: DarkBlue;
text-align: center;
}
.zoom {
transform-origin: 40% 50% 0;
transition: transform .2s;
margin: 0 auto;
}
.zoom img{
width:auto;
height:auto;
}
.zoom:hover {
transform: scale(2);
}
th, td {padding: 5px;}
</style>
```
<hr></hr>
For this first exercise you will be examining how you can use various software for geospatial analysis and graphical display of spatial data. Because of the variety and availability of operating systems in use today, each of the exercises in this course can be completed in either **[ArcGIS Pro]{style="color:#ff4500"}**, **[QGIS]{style="color: #006400"}**, or **[R]{style="color: #6495ED"}**. Each of these software have their pro's and con's but for simplicity purposes here is a table that might suggest which software would be best for you:
| [ArcGIS Pro]{style="color:#ff4500"} | [QGIS]{style="color: #006400"} | [R]{style="color: #6495ED"} |
| --- | --- | --- |
| Available on <u>Windows PC Only</u> | Available for PC, Mac, or Linux (limited) | Available for PC, Mac, Linux, ChromeOS, iOS, or Android via web modern browser|
| Available by subscription only | Open Source | Open Source |
| Graphical User Interface with built-in functionality for Python; add-ons available for statistical languages | Graphical User Interface with built-in functionality for Python; use of plug-ins for other languages and analyses | Scripting language, mostly used for statistical purpose; packages expand its use to other applications such as geospatial analyses |
| Widely used in academia, government, and industry jobs | Widely used in academia and industry | Predominantly used in academia, research, and specialized industry jobs |
Help available at [ESRI.com](https://pro.arcgis.com/en/pro-app/latest/help/main/welcome-to-the-arcgis-pro-app-help.htm) and through various outlets via a google search | Help available at [QGIS.org](https://docs.qgis.org/3.16/en/docs/user_manual/) and through sites like stackoverflow.com or other sites via google search | Help available through individual package [documentation](https://cran.r-project.org/web/packages/available_packages_by_name.html) and sites like stackoverflow.com or other sites via google search
For the purposes of this course, you can complete the laboratory exercises in any of these software. There will be drop-down menus in every lab color-coded for the three software. Ultimately, you will have access to all of this material during and after the course and while the steps might be different between each version the outcomes will be the same. So if you choose to complete the course with one software you can always go back and complete the work in another software in your own time.
While all of the software will be available on the computers in McCord 210, if you choose to use **[ArcGIS Pro]{style="color:#ff4500"}** you will need to contact the APSU GIS Center with your student information to obtain a one year license for your personal computer. **[QGIS]{style="color: #006400"}** is available for download using this **[link](https://qgis.org/en/site/forusers/download.html){style="color: #006400"}**. If you are completing the course in **[R]{style="color: #6495ED"}** you will not need to install any software, however you will need a [Google account](https://accounts.google.com/signup/v2/webcreateaccount) and access to the [Chrome browser](https://www.google.com/chrome/). When using **[R]{style="color: #6495ED"}** you will be completing all of the lab exercises in the [Google Colaboratory](https://colab.research.google.com/) and will access everything you need from the exercise pages on _GitHub_.
More information for each software and the steps to complete this exercise can be found below. Be sure to follow the color-coded drop-down for the specific software you are using for the lab.
<details>
<summary><big>View information for <b> [ArcGIS Pro]{style="color:#ff4500"} </b></big></summary>
<b>[ArcGIS Pro]{style="color:#ff4500"}</b> is a proprietary software from [ESRI](https://www.esri.com/en-us/home). Student access is available in McCord 210 and several other computer labs on campus. If you wish to obtain the software for use on your personal computer (Windows-based PC only) you will need to contact the [APSU GIS Center](https://www.apsugis.org/) at 601 N 2nd St, Clarksville, TN 37040, (931) 221-7500. Please have your APSU student ID and A# available for verification prior to obtaining a license. Please contact the GIS Center if you have any issues downloading or installing the software.
</details>
<hr></hr>
<details>
<summary><big>View information for <b> [QGIS]{style="color: #006400"} </b></big></summary>
If you will be using <b>[QGIS]{style="color: #006400"}</b> for the exercises you will need to have the software installed on your computer. **QGIS** is available for PCs, Mac, and Linux computers. You can find the appropriate download for your operating system here:
- [PC version, 3.16](https://qgis.org/downloads/QGIS-OSGeo4W-3.16.6-1-Setup-x86_64.exe)
- [macOS version, 3.16](https://qgis.org/downloads/macos/qgis-macos-ltr.dmg)
- [Linux version, 3.x](https://qgis.org/en/site/forusers/alldownloads.html#linux)
When installing on _macOS_ for the first time you may need to go to _Systems Preferences > Security and Privacy_ and on the _General_ tab "Allow apps downloaded from" _App Store and identified developers_ and click _Open Anyway_. Please contact your instructor if you have any issues downloading or installing the software.
</details>
<hr></hr>
<details><summary><big>View information for <b> [R]{style="color: #6495ED"} </b></span></big></summary>
You will be completing the <b>[R]{style="color: #6495ED"}</b> portion of each exercise using the _[Google Colaboratory Executable Environment](https://colab.research.google.com/)_. Colaboratory, or _"colab"_ for short, is based on the popular Jupyter Notebooks and allows you to write and execute **R** or _Python_ in your browser, with:
- Zero configuration required
- Free access to GPUs
- Easy sharing
Each _colab_ notebook is separated into code cells and text cells. A code cell is used to write and execute a script interactively. Each text cell uses simple [markdown](https://www.markdownguide.org/) syntax for creating plain text information. You can easily share the notebook like other Google Drive based documents by clicking the "Share" link in the upper right-hand portion of the window.
Before beginning each exercise using **R**, you will need to open the [Exercise Colab Notebook](https://githubtocolab.com/chrismgentry/GIS-Exercise-2/blob/main/GIS1_EX2.ipynb) and alter the URL to view/edit the file in colab. To do this you will navigate to the exercise's GitHub page; in this case [https://github.com/chrismgentry/GIS1-Exercise-2](https://github.com/chrismgentry/GIS1-Exercise-2). In the list of folders and files you will find a file that will always be identified as _GIS1_EX_ followed by the exercise number and a _.ipynb_ file extension. So for this exercise it will be [GIS1_EX2.ipynb](https://github.com/chrismgentry/GIS1-Exercise-2/blob/main/GIS1_EX2.ipynb)
<p align="center"><img src= "Images/r-github-ipy-location.png" alt="Finding the Google Colab file on GitHub" style="width:100%"></p>
<br>
When you locate the file, click on the name to open the _ipy_ notebook. In the resulting window, click on the URL and insert **tocolab** immediately after _github_ in the address. So the new URL for this exercise should now read:<br> ```https://githubtocolab.com/chrismgentry/GIS-Exercise-2/blob/main/GIS1_EX2.ipynb```
<p align="center"><img src= "Images/r-github-tocolab.png" alt="Converting ipy file to colab" style="width:100%"></p>
<br>
Click enter/return and the file should now open inside of _Colab_. Your screen might have a slightly different appearance, but you should see the Exercise 2, GIS 1 header indicating you are in the correct notebook.
<p align="center"><img src= "Images/r-colab.png" alt="Converting ipy file to colab" style="width:100%"></p>
<br>
Each time you open these colab notebooks, or if you have not interacted with the notebook for an extended period of time, you will need to make sure the environment is connected and all of the sample script has been run. To do this go to _Runtime > Run all_ (or click CRTL+F9) and run the notebook. This may take a moment to complete so be patient until the last code cell has been executed. You should see a green check mark with an allocation of RAM and Disk as shown by horizontal bars which will indicate you are connected. In each section of code there is a **Run cell** <img src= "Images/r-colab-run-code.png" alt="Run cell button" width="15" height="15"> button that will allow you to run the individual code cells. This button will have a rotating loading symbol <img src= "Images/r-colab-loading.png" alt="Run cell button" width="15" height="15"> while the code cell is being executed. Once it is complete the box will return to the run state and there may be an output visible depending on the script. You can add your own text or code cells to a notebook simply by moving your cursor slowly over the notebook to reveal the code/text option bar or by going to _Insert > Code cell/Text cell_.
<p align="center"><img src= "Images/r-colab-code-text.png" alt="Adding Text or Code Blocks" style="width:100%"></p>
<br>
By clicking within each code or text cell you can edit the contains and adjust the properties using the various preset option controls.
<p align="center"><img src= "Images/r-colab-block-settings.png" alt="Edit block properties" style="width:100%"></p>
<br>
You should practice adding and removing cells, editing their content, and rearranging the order of the cells. This will help familiarize you with notebook tools and allow you to manipulate notebooks in these exercises and create your own notebooks in the future.
For each new exercise there will be a colab notebook available. Within the notebook will be sample code for you to run, code cells for you to complete as part of the exercise and questions to be answered within labeled text cells. Detailed directions will be available on the individual exercise webpage. Each completed exercise will have completed code and question sections and the notebook link shared for a grade.
</details>
# The Introduction
The Tennessee Valley Authority (TVA) and Tennessee Department of Environment and Conservation (TDEC) are considering a partnership to increase the number of electric vehicle charging stations across the state. With destinations such as Nashville, Memphis, Gatlinburg and the Great Smoky Mountains, Bristol Motor Speedway, Signal Mountain and the Tennessee Aquarium, tourism is a major part of the state's economy. So accommodating residents and visitors with electric vehicles as well as creating a network for those traveling the states major interstates (I-65, I-40, I-24, I-75, etc.) is of utmost importance.
TDEC says this network of charging stations will also promote electric vehicle growth by giving drivers confidence they will have easy access to refueling while away from home, eliminating so-called “range anxiety” that keeps many consumers from considering electric vehicles as viable transportation. TVA says electric vehicle adoption will spur jobs and economic investment in the region, keep refueling dollars in the local economy, reduce the regions largest source of carbon emissions, and save drivers and fleets money.
So TVA and TDEC have asked you to develop a map showing the number of public electric vehicle charging stations in the continental United States. This will help them understand what the nations current infrastructure looks like and how Tennessee currently compares to neighboring states. It will also help TVA and TDEC determine approximately how many additional stations they should add.
In this exercise you will:
- Navigate software used for geospatial analysis
- Examine attributes of various datasets
- Learn how to graphically display spatial data
- Create a cartographically sound product
Software specific directions can be found for each step below. Please submit the answer to the questions and your final map by the due date.
## Step One: The Data
In this step you will learn how to obtain data, load it into the software, examine the attributes, and make a simple display.
<details>
<summary><big>View Directions in <b> [ArcGIS Pro]{style="color:#ff4500"} </b></big></summary>
The purpose of this exercise is to help familiarize you with the [ArcGIS Pro]{style="color:#ff4500"} program. With this software, you will have the ability to view, create, and edit geographic data, query spatial data, examine spatial relationships, and create publishable maps. To launch ArcGIS Pro, click on the start menu and search for the ArcGIS Folder. Within the folder click on the **ArcGIS Pro** icon to open.
<p align="center"><img src= "Images/arcgis-pro.png" alt="Data Download from GitHub" width="260" height="320"></p><br>
After the initial splash screen, you'll be greeted with a screen that allows you to open previous recently saved projects, new map templates, and view various resources from ESRI. For this exercise you will begin by clicking **Map** under the _New > Blank Templates_ section in the middle of the screen.
<p align="center"><img src= "Images/arcgis-splash-screen.png" alt="ArcGIS Pro Open Screen" style="width:100%"></p><br>
This will open a new _Create a New Project_ screen that will ask you to give your new project a name and a location on your computer to save the project. At this point I would recommend creating a folder somewhere on your PC to store all of your _GIS1_ exercises. If you are in a GIS class using a networked folder, be sure to have that folder mapped and save all of your data under the project folder for this exercise. This will make them easier to locate later on.
<p align="center"><img src= "Images/arcgis-new-project.png" alt="Project name and location" width="520" height="175"></p><br>
After establishing the project, a project file and several folders will be created in your folder, and your screen should appear similar to this:
<p align="center"><img src= "Images/arcgis-open-project.png" alt="New project" style="width:100%"></p><br>
While your screen might appear slightly different, you should have a basemap in the center section, a list of objects under _Map_ in the _Contents_ section on the left (frequently called a table of contents), and possibly a blank section on the right. For this exercise you will need to download the _Electric Vehicle Charging Station_ data from the [GitHub Repository](https://github.com/chrismgentry/GIS1-Exercise-2){style="color:#000000"} by clicking on the download button at <b>[this link](https://github.com/chrismgentry/GIS1-Exercise-2/blob/main/Data/Shapefiles/ev_data.zip){style="color:#ff4500"}</b> and saving it in your exercise folder created above. Once the download is complete you will need to unzip the file by using _right-click > extract all_ on the zipped folder.
<p align="center"><img src= "Images/github-data-download.png" alt="Data Download from GitHub" style="width:100%"></p><br>
This data should now be available for use in your project. To add the information to your map project, navigate to the **Map** tab on the menu bar and find the _Add Data_ button. From here you can click the drop-down menu and see all of the options. For this example you will click _Data, Add data to the map._
<p align="center"><img src= "Images/arcgis-add-data-button.png" alt="Add data button" width="240" height="625"></p><br>
Similar to other PC-based GUI interfaces, a new window will open where you will navigate to your data folder and double-click or single-click and click OK to add the data.
<p align="center"><img src= "Images/arcgis-add-data.png" alt="Add data" width="675" height="465"></p><br>
This will add the data to your map and it will appear in the table of contents. Your screen should now look similar to the one below (colors may vary):
<p align="center"><img src= "Images/arcgis-data-view.png" alt="EV Dataset View" style="width:100%"></p><br>
With this dataset added, you can now begin to explore some of the basic tools for navigating and analyzing the map data. Some information or tools are available in the map view while some are located in each of the various tabs (Map, Insert, Analysis, View, Edit, Imagery, and Share). Additionally, some tabs or information will only become available when data is selected. For example, while on the **Map** tab, if you select the _ev_data_ in the table of contents you will see that **Appearance, Labeling, and Data** tabs all appear. If you select either the _World Topographic Map_ or _World Hillshade_ only **Appearance** is added. If you select _Map_ in the table of contents then all additional options are removed.
Along the bottom of the map view there are several tools available including:
<table style="width:100%">
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<tr>
<td>Representative Fraction</td>
<td>Unit-less relation between map units and real-world units (e.g. 1 unit equals 30,000 units)</td>
</tr>
<tr>
<td>Snapping</td>
<td>Moving a feature to match or coincide exactly with another point or feature's coordinates when your pointer is within a specified distance or tolerance</td>
</tr>
<tr>
<td>Constraints</td>
<td>Limits imposed on a model to maintain data integrity</td>
</tr>
<tr>
<td>Grid</td>
<td>A network of parallel and perpendicular lines superimposed on a map and used for reference</td>
</tr>
<tr>
<td>Inference</td>
<td>Analyzes the segment of the active sketch over which the pointer is hovering and displays inferred geometric constraints</td>
</tr>
<tr>
<td>Corrections</td>
<td>Set grid corrections and offset</td>
</tr>
<tr>
<td>X,Y Coordinates</td>
<td>X,Y location of the cursor; can be set to decimal degrees, degrees minutes seconds, degree decimal minutes, military grid reference system, national grid, or universal transverse mercator</td>
</tr>
<tr>
<td>Selected Features</td>
<td>Depicts the number of items selected from a feature set</td>
</tr>
<tr>
<td>Pausing Drawing</td>
<td>Stops the drawing of layers on the map view</td>
</tr>
<tr>
<td>Refresh</td>
<td>Reloads the map view</td>
</tr>
</table>
<p align="center"><div class="zoom"><img src= "Images/arcgis-data-view-toolbar-markup.png" alt="Map View Toolbar" style="width:100%"></div></p><br>
The mouse can be used to navigate around the map view. The left-click button is used to pan or move the map around the screen and view pop-ups, the scroll wheel is used to zoom or rotate/tilt (3D), and righ-click is used for continuous zoom by clicking and moving the cursor up to zoom out and down to zoom in.
<p align="center"><img src= "Images/arcgis-explore-tool.png" alt="Explore" width="415" height="350"></p><br>
On the **Map** tab there are a number of tools you should become familiar with as they will be useful throughout this course and beyond. Along with the _Add Data_ button you have already used, the _Fixed Zoom In/Out_ tools <img src= "Images/arcgis-zoom-tools.png" alt="Fixed Zoom Tools" width="40" height="20"> are used to adjust the level of zoom. The _Full Extent_ tool <img src= "Images/arcgis-full-extent.png" alt="Full Extent Tool" width="20" height="20"> is used to adjust the level of zoom to include the extent of all datasets. The _Previous Extent_ tool <img src= "Images/arcgis-previous-extent.png" alt="Previous Extent Tool" width="20" height="20"> is used to return the level of zoom to the previous level. There are a number of other tools you will use on this tab in future exercises. You should explore the different buttons on this tab to see what they do.
<p align="center"><div class="zoom"><img src= "Images/arcgis-map-ribbon.png" alt="Map Toolbar" style="width:100%"></div></p><br>
For this exercise you will familiarize yourself with another useful tool that allows you to examine information regarding the dataset. First, click on the _ev_data_ layer in the table of contents. Next, click on the _Explore_ button <img src= "Images/arcgis-explore-button.png" alt="Explore Button" width="20" height="20"> and move the cursor over the map. Your cursor will become a hand with pointed finger. If you click on the state of Tennessee a pop-up window will appear that provides data about the state.
<p align="center"><img src= "Images/arcgis-identify-tool.png" alt="Explore" width="625" height="380"></p><br>
You can scroll down on the data in the pop-up window and examine each attribute in the table. Along the bottom of the window you will see tools that can be used to: print the information for the selected feature <img src= "Images/arcgis-pop-up-print.png" alt="Print the pop-up for this feature" width="20" height="20">, toggle selection on/off for the feature <img src= "Images/arcgis-pop-up-select.png" alt="Toggle selection on/off for this feature" width="20" height="20">, flash the selected feature <img src= "Images/arcgis-pop-up-flash.png" alt="Flash selected feature" width="20" height="20">, and to zoom to the selected feature <img src= "Images/arcgis-pop-up-zoom.png" alt="Zoom to selected feature" width="20" height="20">.
This method is helpful for getting information about a specific portion of the dataset. You can view all of the underlying information in the attribute table by right-clicking on the _ev_data_ layer in the table of contents and clicking on **Attribute Table**.
<p align="center"><img src= "Images/arcgis-rc-attribute-table.png" alt="Explore" width="345" height="200"></p><br>
Alternatively while the _ev_data_ layer is selected in the table of contents you should see three new tabs highlighted in orange (color may vary) and titled **Feature Layer**. Under the **Data** tab you should see the _Attribute Table_ tool.
<p align="center"><div class="zoom"><img src= "Images/arcgis-data-ribbon.png" alt="Map Toolbar" style="width:100%"></div></p><br>
Whichever method you used to open the attribute table you should now have a new section on your screen that displays the attribute data for all of the features in the dataset. In a future exercise you will learn how to sort, query, and edit information within the attribute table. For now, examine the numerous variables available for each state. What is the column name and range of values for the electric vehicle charging stations?<br>
<small>Hint: This information will be needed in the next section.</small>
<p align="center"><img src= "Images/arcgis-attribute-table.png" alt="Attribute Table" style="width:100%"></p><br>
<b><big>Question No. 1</big></b>
<blockquote>
Using the explore tool, what is the population of Tennessee in 2010 (POP2010)? What percentage of the population is female?<br><br>
Using the attribute table, find the area (_SQMI_ ) of Colorado. How much larger is it than Wyoming?
</blockquote>
Type your answers in a word document. The answers will need to be submitted at the conclusion of this lab.
</details>
<hr></hr>
<details>
<summary><big>View Directions in <b> [QGIS]{style="color:#006400"} </b></big></summary>
The purpose of this exercise is to help familiarize you with the [QGIS]{style="color:#006400"} program. With this software, you will have the ability to view, create, and edit geographic data, query spatial data, examine spatial relationships, and create publishable maps. In these directions I will post images from both PC (on the left) and macOS (on the right) for each step. While your set-up may differ slightly, the configurations and layout of the tools should be similar.
When you begin a new exercise it would be beneficial to create a new folder specifically for the data and project files associated with the lab. This will help you to organize your data and be able to quickly refer back to it in later exercises. For this exercise you will need to download the _Electric Vehicle Charging Station_ data from the [GitHub Repository](https://github.com/chrismgentry/GIS1-Exercise-2){style="color:#000000"} by clicking on the download button at <b>[this link](https://github.com/chrismgentry/GIS1-Exercise-2/blob/main/Data/Shapefiles/ev_data.zip){style="color:#006400"}</b> and saving it in your exercise folder. Once the download is complete you will need to unzip the file by using _double-click_ on macOS or _right-click > extract all_ on PC.
<p align="center"><img src= "Images/github-data-download.png" alt="Data Download from GitHub" style="width:100%"></p><br>
To start the QGIS program press the _Start Menu > QGIS_ or launch the application from the _Mac Launchpad_. It might be beneficial to create a shortcut on the desktop or add it to your dock for quicker access in the future. As the program loads, the opening screen will be extremely useful to you while working on future projects, however, for this exercise we will select **New Empty Project**.
<p align="center"><div class="zoom"><img src= "Images/qgis-temp.png" alt="QGIS Start Screen" style="width:100%"></div></p><br>
The screen depicted below is separated into two sections. To the left there is the _Browser_ and _Layers_ sections, and on the right is the _Map Canvas_. Your version may vary slightly from the images. There are a number of ways to add data, but in this example we are going to use the browser window to connect to our project data folder.
<p align="center"><div class="zoom"><img src= "Images/qgis-proj.png" alt="QGIS Start Screen" style="width:100%"></div></p><br>
In the _Browser_ window on the left, navigate to the folder where you saved and unzipped the exercise data folder. Once you locate a folder in folder in the browser, you can use control+click (macOS) or right-click (PC) to **Add as a favorite**. This will link it to the favorites drop-down in the browser window giving you quicker future access. To add the data, you will navigate to the **ev_data.shp** file and then click-and-drag it to the map canvas. You will be able to add all types of data in this same way. If there is a pop-up window that mentions transformations go ahead and click OK. While the look of the US in this dataset is less than ideal, the purpose of this exercise is to ensure you know how to display data and basic tools for navigating the software. Transformations will be discussed further in a couple weeks after a lecture on projections and coordinate systems. For now, leave it with option 1 and click OK.
<p align="center"><img src= "Images/qgis-transformations.png" alt="QGIS Start Screen" style="width:100%"></p><br>
Your screen should now look similar to the screens below (colors may vary). Notice that the longitude and latitude values at the bottom of the screen adjust as you move your cursor.
<p align="center"><div class="zoom"><img src= "Images/qgis-states.png" alt="QGIS Map Canvas" style="width:100%"></div></p><br>
You can now begin to explore some of the basic tools for navigating the _map canvas_ such as:
<table style="width:100%;margin-left:auto;margin-right:auto;">
<tr>
<td><li>Zoom in and out with the <i>Fixed Zoom Tools</i></li></td>
<td><img src= "Images/qgis-fixed-zoom.png" alt="Fixed Zoom Tools" width="40" height="20"></td>
</tr>
<tr>
<td><li><i>Pan tool</i> to postion the map on the screen</li></td>
<td><img src= "Images/qgis-pan.png" alt="Pan Tool" width="20" height="20"></td>
</tr>
<tr>
<td><li><i>Map scale</i> where you can adjust the map scale (level of zoom) manually</li></td>
<td><img src= "Images/qgis-map-scale.png" alt="Map Scale" width="80" height="20"></td>
</tr>
<tr>
<td><li><i>Zoom full</i> button which will adjust the view to accommodate all datasets</li></td>
<td><img src= "Images/qgis-full-extent.png" alt="Zoom Full" width="20" height="20"></td>
</tr>
</table>
<br>
Use these tools to zoom in and out, reposition the map on the screen, and return to the current view using the _zoom full_ button.
Another useful tool is the **identify features** cursor which uses an icon with a lowercase _i_ in a [blue circle]{style="color:#6495ED"} <img src= "Images/qgis-identify.png" alt="Identify Features" width="20" height="20"> . This option extracts information for a selected feature from the attribute table of the selected layer.
<p align="center"><div class="zoom"><img src= "Images/qgis-tennessee.png" alt="Identify Cursor" style="width:100%"></div></p><br>
If you wanted to view the entire underlying dataset you could control-click (macOS) or right-click (PC) on the active layer and select **Open attribute table**. In a future exercise you will learn how to sort, query, and edit information within the attribute table. For now, examine the numerous variables available for each state. What is the column name and range of values for the electric vehicle charging stations? <br>
<small><i>Hint: This information will be needed in the next section.</i></small>
<p align="center"><div class="zoom"><img src= "Images/qgis-attributes.png" alt="Attribute Table" style="width:100%"></div></p><br>
<b><big>Question No. 1</big></b>
<blockquote>
Using the identify tool, what is the population of Tennessee in 2010? What percentage of the population is female?<br><br>
Using the attribute table, find the area (_SQMI_ ) of Colorado. How much larger is it than Wyoming?
</blockquote>
Type your answers in a word document. The answers will need to be submitted at the conclusion of this lab.
</details>
<hr></hr>
<details>
<summary><big>View Directions in <b> [R]{style="color:#6495ED"} </b></big></summary>
For each exercise in **R** you will need to load various packages that are used to complete analyses and graphical output. Generally these packages will be preloaded in the colab notebook however in subsequent labs you may need to install certain packages to complete the exercises. To install a package in **R** you use the following function where ("x") is the name of a specific package.
```
install.packages("x")
```
Once the package has been installed, it will need to be loaded using a similar function:
```
library("x")
```
In the colab notebook for this exercise you will see where three packages _tidyverse, maps, and ggsn_ were installed and loaded. Now that you have the packages required for the exercise you will need to add the data. For this lab the data consists of state names, abbreviations, and the number of electric vehicle recharing stations. To avoid the need to download the data, you will the ```read.csv()``` function and a URL to import the data. Using the ```head()``` function will allow you to view the first few lines of any dataset.
```{r data, echo=TRUE, message=FALSE, warning=FALSE}
evs <- read.csv('https://raw.githubusercontent.com/chrismgentry/GIS1-Exercise-2/main/Data/ev_stations.csv')
head(evs)
```
In the script above you will see the use of **<-**. This is an operator used to create an object that can be used in later steps. If the script was written as ```read.csv('https://raw.githubusercontent.com/chrismgentry/GIS1-Exercise-2/main/Data/ev_stations.csv')``` the dataset would have been read and immediately displayed on the screen. However, it would not have been available for subsequent analyses. In colab, you can create your own code block and test it out to see the results. Since you need this information for later, it is important to use **<-** to create an object out of the imported data. In this, and future exercises, you will see that operator used frequently to create objects for analysis.
In order to create a map of electrical vehicle charging stations per state you need to obtain information for the states and create a new object. The ```tidyverse``` package is a retainer for a number of individual packages including the _Grammar of Graphics_ or _ggplot2_ package. This package will frequently be used to display your data, but it also contains geographic information for the US. You can obtain that information by using the ```map_data``` function. In a new code block, you can use ```?map_data``` to view help information on the function. Alternatively you can view the documentation for any package or function by searching the package or function name and cran _(Comprehensive R Archive Network)_. For this function you would search ```map_data cran``` and the first link is likely to be the [RDocumentation page](https://www.rdocumentation.org/packages/ggplot2/versions/3.3.3/topics/map_data) for the function. Within this documentation you will find the arguments available for the function and example scripts. So to create an object that contains information for the continental US you can use:
```{r states, echo=TRUE, message=FALSE, warning=FALSE}
us <- map_data('state')
```
Using the _Grammar of Graphics_ package, ```ggplot2```, you can create a visualization of this data. Here is that script:
```{r states map, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(us) +
geom_polygon(aes(x=long, y=lat, group=group), color = "white")
```
In this script you identified that you wanted to use ```ggplot``` to visualize the **us** object you created in the previous step. Next ```ggplot``` needs to know what sort of object to draw. This is done by using the ```geom_``` function followed by a type of geometry. They include point, line, polygon and other geometries such as histograms, boxplots, violin plots for statistics, or contours, rasters, and tiles for three dimensional data. So for this step you used ```geom_polygon```. Next, ```ggplot``` needs to know how the data should be displayed. If you create a new code block and type ```str(us)``` you can see the structure of the data and a few of the variables. You will notice the dataset contains _long_ (longitude), _lat_ (latitude), _group_, _order_, _region_ (the state names), and _subregion_. So in ```ggplot``` you provide a series of aesthetics using ```aes()``` to direct ```ggplot``` on how to display the data. In this case, ```x = long, y = lat```, and you need to tell it to organize the groups by the category group. If you leave out _group_ for this specific script, ```ggplot``` will be unsure what order to draw the polygons and your map will not appear correctly. ```color = "white"``` tells ```ggplot``` to use white borders for the individual states. What do you think would happen if you change the word **_color_** to **_fill_** ? In the resulting image, ```ggplot``` used the information from your aesthetics to draw the polygons and automate labels for the x and y axes. In a later step you will learn how to customize those labels.
It may seem as if this is a difficult way to view the data. In other software with a graphical user interface (GUI) you would most likely click open, navigate to the folder containing the data, double-click on that dataset, and then it would appear on your screen. Essentially, every time you click "open" on a GUI interface, it is executing a specific set of scripts to 1.) open the navigation window, 2.) allow the selected file to be imported, and 3.) then display the information on your screen. What you did above in three lines of code was to tell ```ggplot``` to 1.) create an object called _us_ and 2.) display it on the screen with some specific parameters. The benefit of completing this in **R** versus something with a GUI interface is, if you had three more similar datasets to view, you would simply change _US_ to another object and re-run the script. To repeat the process in a GUI interface you would need to repeat all of the steps from the beginning. This might not seem like much for three steps, but what if your visualization had twenty steps, as many do? In **R** you would still simply change the dataset and run the same script, but in other programs you would need to repeat the same twenty steps for each dataset. Additionally, if a colleague wanted to display some data in the same way, you can either copy and paste the code or type out each of the twenty steps with directions. Which of these seems to be more consistently repeatable? Once you begin to understand the syntax (order or arrangement of words and phrases to form proper scripts) you will be more easily able to interpret sample scripts and fix errors in your own code.
<big><b>Question No. 1</b></big>
<blockquote>
You used ```ggplot(us) + geom_polygon(aes(x=long, y=lat, group=group), color = "white")``` to create the visualization in this step. What script would you use to make the same map but with _black_ borders and _blue_ states? Add a code cell below this one, type the script, and run it to view the output.
<small>Hint: color = ".....", fill = "....."</small>
</blockquote>
</details>
## Step Two: The Analysis
In this step you will organize and display the data in order to prepare it for the final visualization.
<details>
<summary><big>View Directions in <b> [ArcGIS Pro]{style="color:#ff4500"} </b></big></summary>
Now that you have the data displayed on the screen and understand how to access the underlying data, you need to customize the view so you can see the spatial distribution of electric vehicle charging stations in the US. As you may have guessed by now, there are a number of different ways to access the symbology tool needed to change how the data is displayed.
1. Right-click on _ev_data_ in the table of contents and click **Symbology**
2. With _ev_data_ selected in the table of contents click on the _Apperance_ Tab and click the **Symbology** button
3. With _ev_data_ selected in the table of contents click on the **Symbology** tab at the bottom of the right side panel of the screen.
All three of these methods will show the symbology options in a panel on the right side of the screen. From here you will need to change the _Primary Symbology_ from **Single Symbol** to **Graduated Color**. This can also be done by clicking on the drop-down menu for **Symbology** in the _Apperance_ Tab.
<p align="center"><div class="zoom"><img src= "Images/arcgis-symbology-tab.png" alt="Symbology" style="width:100%"></div></p>
After selecting _Graduated Colors_ you will have several other options available in the symbology window. In order to sort by the number of electric vehicle charging stations per state you will need to change the _Field_ category to **ev_station**. Next, in the _Method_ category to **Geometric Interval**. Because of the range of values, choosing this option will help to balance out the bias of larger values. In the _Classes_ category choose 5. Finally using the drop-down menu next to _Color Scheme_, select a color option for your visualization.
<p align="center"><img src= "Images/arcgis-viridis.png" alt="Symbology options" width="300" height="525"></p><br>
Depending on the color scheme you chose, your screen should now look similar to this:
<p align="center"><img src= "Images/arcgis-ev-display.png" alt="Symbology" style="width:100%"></p>
On the left in the table of contents beneath the _ev_data_ layer you will see the range of values represented by each color matching those values for each individual state on your map. At this point you should save your work. This can be done by going to the _Project Tab > Save_ , using the _CRTL+S_ keyboard shortcut, or using the quick save button <img src= "Images/arcgis-quick-save.png" alt="Save project" width="20" height="20"> to save your current project.
<big><b>Question No. 2</b></big><br>
In this step you used a _Graduated Colors_ symbology to visualize the data and organized the values using a **Geometric Interval** method. There are several other options within _Method_ that could have been selected as a display method such as:
<p align="center"><img src= "Images/arcgis-symbology-method.png" alt="Symbology methods" width="225" height="410"></p><br>
<blockquote>
Adjusting the _Method_ value, describe how the visualization changes with each of these different options.
</blockquote>
Record your answers and submit at the conclusion of the lab.
</details>
<hr></hr>
<details>
<summary><big>View Directions in <b> [QGIS]{style="color:#006400"} </b></big></summary>
Now that you have the data displayed on the screen and understand how to access the underlying data, you need to customize the view so you can see the spatial distribution of electric vehicle charging stations in the US. To begin you will need to control-click (macOS) or right-click (PC) on the **ev_data** in your _layers_ and click on properties.
<p align="center"><img src= "Images/qgis-rcproperties.png" alt="Right Click Properties" style="width:60%"></p><br>
In the resulting window you will need to go to the **Symbology** tab (<i>1.</i>) in the left-hand menu. In this window you can change the fill of the polygons and change their opacity (or level of transparency). You can also adjust the symbology of your dataset. Those options are available in a selection bar at the top of the window. For this dataset they are:
<table style="width:50%;margin-left:auto;margin-right:auto;">
<tr>
<td><li>No Symbol</li></td>
<td><img src= "Images/qgis-no-symbols.png" alt="No Symbols" width="20" height="20"></td>
</tr>
<tr>
<td><li>Single Symbol</li></td>
<td><img src= "Images/qgis-single-symbol.png" alt="Single Symbol" width="20" height="20"></td>
</tr>
<tr>
<td><li>Categorized</li></td>
<td><img src= "Images/qgis-categorized-symbol.png" alt="Categorized Symbols" width="20" height="20"></td>
</tr>
<tr>
<td><li>Graduated</li></td>
<td><img src= "Images/qgis-graduated-symbol.png" alt="Graduated Symbols" width="20" height="20"></td>
</tr>
<tr>
<td><li>Rule-based</li></td>
<td><img src= "Images/qgis-rule-based-symbol.png" alt="Rule Based Symbols" width="20" height="20"></td>
</tr>
<tr>
<td><li>Inverted Polygons</li></td>
<td><img src= "Images/qgis-invpoly-symbol.png" alt="Inverted Polygon Symbols" width="20" height="20"></td>
</tr>
<tr>
<td><li>2.5 D</li></td>
<td><img src= "Images/qgis-25D-symbol.png" alt="2.5 D Symbols" width="20" height="20"></td>
</tr>
</table>
<br>
For this specific data you will choose _Graduated_ (<i>2.</i>) since the data needs to be displayed by a range of numeric values. Next you will select the **ev_station** variable (<i>3.</i>) in the dataset. In the drop-down for the _Color ramp_ option you have a number of color options to choose. For this example select **Viridis** (<i>4.</i>). Do you recall what the range of values for the **ev_station** data? Because the largest value is greater than 30,000 and the smallest value is around 100, you will need to set the _Mode_ to a _logarithmic scale_ (<i>5.</i>) to properly display the data while avoiding a bias of the larger values. Change the _Classes_ to 6 (<i>6.</i>) and click **OK** (<i>7.</i>).
<p align="center"><div class="zoom"><img src= "Images/qgis-symbology-options.png" alt="Symbology Properties" style="width:100%"></div></p>
<p align="center"><small><b>Because the macOS and PC versions are identical only one image is shown.</b></small></p><br>
Your screen should now look similar to this:
<p align="center"><div class="zoom"><img src= "Images/qgis-viridis.png" alt="Graduated Data" style="width:100%"></div></p>
At this point you should save your work. Whether using macOS or PC, on the menu bar go to _Project > Save As..._ and save your project in the folder you create for this exercise.
<big><b>Question No. 2</b></big><br>
In this step you used a _Graduated_ symbology to visualize the data and organized the values _logarithmically_. There were several other options within _mode_ menu.
<table style="width:75%;margin-left:auto;margin-right:auto;">
<tr>
<td><li>Equal Count (Quantile)</li></td>
<td><img src= "Images/qgis-equal-count.png" alt="Equal Count" width="140" height="20"></td>
</tr>
<tr>
<td><li>Equal Interval</li></td>
<td><img src= "Images/qgis-equal-interval.png" alt="Equal Interval" width="140" height="20"></td>
</tr>
<tr>
<td><li>Logarithmic Scale</li></td>
<td><img src= "Images/qgis-log-scale.png" alt="Logarithmic Scale" width="140" height="20"></td>
</tr>
<tr>
<td><li>Natural Breaks (Jenks)</li></td>
<td><img src= "Images/qgis-jenks.png" alt="Natural BReaks (Jenks)" width="140" height="20"></td>
</tr>
<tr>
<td><li>Pretty Breaks</li></td>
<td><img src= "Images/qgis-pretty-breaks.png" alt="Pretty Breaks" width="140" height="20"></td>
</tr>
<tr>
<td><li>Standard Deviation</li></td>
<td><img src= "Images/qgis-sd.png" alt="Standard Deviation" width="140" height="20"></td>
</tr>
</table>
<blockquote>
Adjusting the _mode_ value, describe how the visualization changes with each of these different options.
</blockquote>
Record your answers and submit at the conclusion of the lab.
</details>
<hr></hr>
<details>
<summary><big>View Directions in <b> [R]{style="color:#6495ED"} </b></big></summary>
Now that you have datasets for electric vehicle charging stations (object = **evs**) and the continental US (object = **us**), you need to combined that data to allow for the states to be color coded based on the number of charging stations per state. To do this you will use a function called ```merge``` from the base **R** functions that will allow you to combine the information from the **evs** and **us** into a single dataset that contains information from both based on a common variable. So to start you will need to determine what variable(s) are contained within each dataset. You have seen how to examine datasets using both ```head()``` and ```str()``` already in this exercise. Create a new code block and examine the structure of each dataset. You will see that there is a column for state name in each except they are labeled differently. This is important information you will need to properly ```merge``` the datasets.
To do this you will first create an object (**<-**) with a new name, then with the ```merge``` function set the following arguments:
- x, which is the first data set
- y, which is the second dataset
- by.x, identifies the column to use for the merge in x
- by.y, identifies the column to use for the merge in y
- all = TRUE, which tells the function to retain all data
So your final script will be:
```{r merged datasets, echo=TRUE, message=FALSE, warning=FALSE}
states <- merge(x = us, y = evs, by.x = "region", by.y = "state", all = TRUE)
head(states)
```
Now you will see the columns for **evs** and **abbreviation** included in the **us** dataset. This new dataset will be what you use to visualize the information in the next step.
<big><b>Question No. 2</b></big>
<blockquote>
Using ```summary(states)``` in a new code cell, what are the largest and smallest number of electric vehicle charging stations?
</blockquote>
</details>
## Step Three: The Visualization
You will learn how to create a graphical display of your data that includes cartographic elements such as legend, scale bar, north arrow, etc.
<details><summary><big>View directions in <b> [ArcGIS Pro]{style="color:#ff4500"} </b></span></big></summary>
Now it’s time to turn your data into a map. From the _Insert_ Tab click on the **New Layout** button <img src= "Images/arcgis-new-layout-button.png" alt="New layout button" width="20" height="20"> and choose a paper layout. For this exercise you should choose _ANSI - Landscape, Letter 8.5" x 11"_. This will open a new section where you will add the data, title, legend, north arrow, scale bar, and your name and date. If you have a large enough screen, you can right-click on the new layout <img src= "Images/arcgis-layout.png" alt="Layout tab" width="80" height="20"> and select **Float**. This will create a new window that you can resize while keeping the primary screen open. Otherwise, resize the layout section as necessary by moving your cursor between the two sections to adjust the border.
<p align="center"><img src= "Images/arcgis-layout-map.png" alt="Side-by-side Map and Layout" style="width:100%"></p>
Whether viewing the new layout in a new window or section on the map page, click on the _Insert_ tab and choose the **Map Frame** button. From there, select the map that has a representative fraction and has an image of the data from the map view.
<p align="center"><div class="zoom"><img src= "Images/arcgis-map-insert-ribbon.png" alt="Map Insert Tab" style="width:100%"></div></p>
When placed over the layout our cursor will become cross-hairs (+). Use it to draw the location of the map on the layout.
<p align="center"><img src= "Images/arcgis-draw-map-frame.png" alt="Insert the map frame" style="width:100%"></p>
Your map will now be imported to the layout. To zoom in or out you can adjust the representative fraction at the bottom of the layout or on the _Layout_ tab use the **fixed zoom** tools <img src= "Images/arcgis-zoom-tools.png" alt="Fixed zoom tools" width="40" height="20"> to change the level of zoom.
<p align="center"><div class="zoom"><img src= "Images/arcgis-map-layout-ribbon.png" alt="Map Layout Tab" style="width:100%"></div></p>
To adjust the location of the data, click the **Activate** button <img src= "Images/arcgis-activate-button.png" alt="Navigate Button" width="20" height="20"> and use the **Explore Button** <img src= "Images/arcgis-explore-button.png" alt="Navigate Button" width="20" height="20"> to click and drag and move the data on the map frame on the layout. When finished adjusting the view deactivate the layout by clicking the _Close activated map frame_ button <img src= "Images/arcgis-return-layout.png" alt="Close activate map frame" width="150" height="20"> to return to the map layout. After you have adjusted the zoom and positioning your layout should look like this:
<p align="center"><div class="zoom"><img src= "Images/arcgis-layout-image.png" alt="Map and Layout" style="width:100%"></div></p>
In order to complete a basic map you will need to add a north arrow <img src= "Images/arcgis-north-button.png" alt="Add north arrow" width="20" height="20">, scale bar <img src= "Images/arcgis-scale-button.png" alt="Add scale" width="20" height="20">, legend <img src= "Images/arcgis-legend-button.png" alt="Add legend" width="20" height="20">, and text <img src= "Images/arcgis-text-button.png" alt="Add text" width="20" height="20"> to include a title and the name and date of the map creator. Each of these items works essentially the same as adding the map data. When you click on each tool you can use your cursor to draw its location on the map. You will notice with the north arrow and scale bar there is a drop-down menu that allows you to select the specific style.
<p align="center"><img src= "Images/arcgis-item-drop-down.png" alt="Drop-down information for north arrow and scale bar" style="width:100%"></p>
Each time you add an element such as a north arrow or scale bar, you will notice the section on the right will provide a number of different options to customize the element. Depending on the element you are adding there will be different buttons such as:
<table style="width:100%">
<colgroup>
<col style="width: 20%;">
<col style="width: 10%;">
<col style="width: 70%;">
</colgroup>
<tr>
<td>Options</td>
<td><img src= "Images/arcgis-element-options.png" alt="Options button" width="20" height="20"></td>
<td>Allows you to make elements visible or locked, change the title of the element, adjust the labels, or add columns</td>
</tr>
<tr>
<td>Display</td>
<td><img src= "Images/arcgis-element-display.png" alt="Display button" width="20" height="20"></td>
<td>Lets you adjust the border, background, or add a shadow to the element</td>
</tr>
<tr>
<td>Placement</td>
<td><img src= "Images/arcgis-element-placement.png" alt="Placement button" width="20" height="20"></td>
<td>Allows you to fine tune adjust the location of the element on the map and change the appearance and format of the text symbol of the element</td>
</tr>
<tr>
<td>Properties</td>
<td><img src= "Images/arcgis-element-properties.png" alt="Properties button" width="20" height="20"></td>
<td>This is specific to the scale bar and lets you adjust the number of divisions, numbers, marks, and bars of the element</td>
</tr>
<tr>
<td>Arrangement</td>
<td><img src= "Images/arcgis-element-arrangements.png" alt="Arrangement button" width="20" height="20"></td>
<td>Legend arrangement options allows you to adjust the fitting strategy, word wrap, and spacing of items within the element</td>
</tr>
</table><br>
<p align="center"><div class="zoom"><img src= "Images/arcgis-add-elements.png" alt="Add element options for north arrow" style="width:100%"></div></p>
These will provide additional customization options for each element. When adding the **Legend**, notice that the information from the layer is added to the element. While you will examine how to customize all elements in future exercises, for this lab you will edit the names of the _layer name_ and _heading_ for the layer. This will update the information automatically in the legend. To begin, click once on the _ev_data_ layer name in the table of contents. This will select the item. By single clicking an additional time (not double-clicking) it will allow you to directly edit the data.
<p align="center"><img src= "Images/arcgis-edit-legend-text.png" alt="Edit layer name and heading" width="455" height="330"></p><br>
Rename the layer **Charging Stations** and rename the _ev_station_ heading to **Number per State**. Depending on placement and symbology color, your legend should now look like this:
<p align="center"><img src= "Images/arcgis-edited-legend.png" alt="New legend layer name and heading" width="190" height="185"></p><br>
Depending on where you placed your elements and customizations you employed, you should now have a completed map that includes all of the necessary elements discussed above.
<p align="center"><img src= "Images/arcgis-ex2-map.png" alt="Exercise 2 example map" style="width:100%"></p>
<big><b>Question No. 3</b></big>
<blockquote>
What is the largest and smallest number of electric vehicle charging stations?
</blockquote>
</details>
<hr></hr>
<details><summary><big>View directions in <b> [QGIS]{style="color:#006400"} </b></span></big></summary>
Now it's time to turn your data into a map. From the menu bar in either macOS or PC click _Program > New Print Layout_. This will open a new window where you will add the data, title, legend, north arrow, scale bar, and your name and date.
<p align="center"><div class="zoom"><img src= "Images/qgis-new-print-layer.png" alt="New Print Layout" style="width:100%"></div></p>
It will first ask you to create a print layout title. After you input a title clock OK.
<p align="center"><img src= "Images/qgis-name-print-layout.png" alt="Name Print Layout" style="width:80%"></p>
In the new window you will see a blank layout page. If you control-click (macOS) or right-click (PC) on the page you will see options for **Page Properties...** that allows you to adjust the page size, orientation (landscape or portrait), or customize the width and height and provide a background color to the layout.There will also be an option to **Manage Guides for Page...** which will allow you to add or remove _Horizontal_ or _Vertical Guides_ that will help align items on the layout.
To add your data to the layout you will use the **Add map** tool <img src= "Images/qgis-add-map.png" alt="Add Map Button" width="20" height="20"> that is located in the column of tools on the left side of the screen. When you select this tool and hover over the page layout your cursor will become a plus symbol. You will use this to draw a bounding box on the page layout that will serve as the location for the map data.
<p align="center"><div class="zoom"><img src="Images/qgis-add-map-box.png" alt="Add Map Box" style="width:100%"></div></p>
Once you have drawn the map box, the information displayed on the map canvas will be added to the print layout. Your screen should now look similar to this:
<p align="center"><div class="zoom"><img src="Images/qgis-map-added.png" alt="Map canvas displayed on print layout" style="width:100%"></div></p>
In order to complete a basic map you will now need to add a north arrow <img src= "Images/qgis-add-north-arrow.png" alt="Add North Arrow" width="20" height="20"> , scale bar <img src= "Images/qgis-add-scale-bar.png" alt="Add Scale Bar" width="20" height="20"> , legend <img src= "Images/qgis-add-legend.png" alt="Add Legend" width="20" height="20"> , and text <img src= "Images/qgis-add-text.png" alt="Add Text" width="20" height="20"> to include a title and the name and date of the map creator. Each of these items works essentially the same as adding the map data. They can also be added through _Add Item_ in the menu bar. There are several other buttons you should familiarize yourself with on the layout page such as:
<table style="width:100%">
<colgroup>
<col style="width: 20%;">
<col style="width: 10%;">
<col style="width: 70%;">
</colgroup>
<tr>
<td>Pan</td>
<td><img src= "Images/qgis-pan-layout.png" alt="Pan Layout" width="20" height="20"></td>
<td>The <i>Pan Tool</i> is used to shift the map canvas. This is useful when the canvas is larger than your display due to the level of zoom</td>
</tr>
<tr>
<td>Zoom</td>
<td><img src= "Images/qgis-layout-zoom.png" alt="Layout Zoom" width="20" height="20"></td>
<td>The <i>Zoom Tool</i> is used to increase the magnification of the map canvas, but is not used to zoom in on the data</td>
</tr>
<tr>
<td>Move Item Content</td>
<td><img src= "Images/qgis-move-item-content.png" alt="Move Item Content" width="20" height="20"></td>
<td>The <i>Move Item Content Tool</i> is used to move the map information within the bounding box and allows you zoom in and out on the map data</td>
</tr>
<tr>
<td>Select/Move Item</td>
<td><img src= "Images/qgis-select-move.png" alt="Select and Move Item" width="20" height="20"></td>
<td>The <i>Select/Move Item Tool</i> is used to move items such as the north arrow on the map canvas</td>
</tr>
<tr>
<td>Lock/Unlock Items</td>
<td><img src= "Images/qgis-lock-buttons.png" alt="Lock and Unlock All Items" width="44" height="20"></td>
<td>Locking items keeps any changes from being made to the items on the layout</td>
</tr>
<tr>
<td>Group/Ungroup Items</td>
<td><img src= "Images/qgis-group-buttons.png" alt="Group and Ungroup Items" width="44" height="20"></td>
<td>These <i>tools</i> allow selected items to be grouped in order to remain together when moved</td>
</tr>
<tr>
<td>Raise/Align Items</td>
<td><img src= "Images/qgis-arrange-buttons.png" alt="Rearrange and Align Items" width="44" height="20"></td>
<td>These <i>tools</i> allow for items to be placed above or below another in their hierarchy or allows selected items to be aligned</td>
</tr>
</table><br>
Once you choose the object you want to add, your cursor becomes a plus symbol and you are then able to draw the object in the desired location. Once you have placed each of the items, select any one, and in the control-click (macOS) or right-click (PC) menu choose **Item Properties**. This will open a new menu to the right of the screen that allows you to edit various properties like the symbol for the north arrow, scale bar units, legend item arrangement, and the text variables for the title, name and date.
<p align="center"><div class="zoom"><img src="Images/qgis-item-properties.png" alt="Item Properties Menu" style="width:100%"></div></p>
Take your time to examine the various options within each of the properties menus. As you continue to make maps you will become more familiar with these menus and begin to develop your own style for each item. <small><i>Hint: do not make the north arrow too large.</i></small> At this point you should save the project.
Because the electric vehicle charging station data was organized logarithmically you can see that the values are displayed in scientific notation. Additionally, the display heading is the same as the name of the dataset. So to correct that you will return to the map canvas. If at any point you accidentally close the _Print layout_ you can always open it again by clicking **Show Layout Manager** <img src= "Images/qgis-layout-manager.png" alt="Add Scale Bar" width="20" height="20"> on the main toolbar. In the window select the layout you created and click _Show_.
Back in the layers area, control-click (macOS) or right-click (PC) on the **ev_data** layer and go to _Properties_ and the _Symbology_ tab on the left. from there you will see the options you selected earlier in the exercise. In the classes section, you will see three (3) columns of information: Symbol, Values, and Legend. The information in _Legend_ can be edited by simply double-clicking on the text. Edit each legend entry to match the information in the values column. When you have completed click OK.
<p align="center"><div class="zoom"><img src="Images/qgis-symbology.png" alt="Altering legend information in symbology window" style="width:100%"></div></p>
Finally, control-click or right-click on the dataset in layers and click _Rename Layer_. Give it a name that is representative of the dataset such as "Electric Vehicle Charging Stations". Now return to your layout. If the information has not been updated, click the _Refresh View_ button <img src= "Images/qgis-refresh-view.png" alt="Refresh View" width="20" height="20"> on the toolbar. Your layout should update with all of the changes you made in the _Symbology Tab_. You may also need to adjust the size of the legend now that you have edited the data. This is just one of a number of different ways to edit information for datasets. In future exercises you will examine other editing methods. You should now have a completed map that includes all of the necessary elements discussed above.
<p align="center"><img src="Images/qgis-ex1-final-map.png" alt="Exercise 1 Final Map" style="width:100%"></p>
<big><b>Question No. 3</b></big>
<blockquote>
What is the largest and smallest number of electric vehicle charging stations?
</blockquote>
</details>
<hr></hr>
<details><summary><big>View directions in <b> [R]{style="color:#6495ED"} </b></span></big></summary>
With this new dataset you are now ready to create a map to examine the distribution of electric vehicle charging stations across the country. In step one you used a very simple script to display the **us** data.
```
ggplot(us) +
geom_polygon(aes(x=long, y=lat, group=group), color = "white")
```
A similar script would allow you to quickly visualize the data ```ggplot(states) + geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white")```, however, you need to add a number of elements in order to create a map such as a scale bar, north arrow, title, etc. Additionally, you can customize other components to provide a better overall visualization.
Earlier in the notebook we installed the ```ggsn``` package. This package allows you to add "north symbols and scale bars for maps created with 'ggplot2' or 'ggmap'." So you can build on the script above to create a map of the information in the **states** dataset. To begin, run the script above with the added **fill** argument to see the outcome:
```{r basic evs map, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) + geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white")
```
One thing you will notice is that the categories are very difficult to distinguish. Because you have wide ranging data in the _evs_count_ column only the largest value is showing. A simple fix to this would be to take the common logarithm of the data to standardize the values by removing the skewness towards larger numbers. The function ```scale-viridis``` scales the data and provides a color map designed to be perceived by viewers with common forms of color blindness. So you can add ```scale_fill_viridis_c(option = "D", trans = "log10")``` to the script above where:
- scale_fill_viridis_c is a fill pattern for continuous data
- option = "D" is the default color option
- There are five color options available with this function
- A = magma
- B = inferno
- C = plasma
- D = viridis
- E = cividis
- trans = "log10" transforms the data using common logarithm, other options are available; see documentation
The new script should now look like this:
```{r log evs map, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) +
geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white") +
scale_fill_viridis_c(option = "D", trans = "log10")
```
Now that you are able to visualize the separations in the data you can add additional information. You can start with customizing the labels, map title, and legend title. This can all be completed by adding a single line of code containing all of the text information for those items:
```{r log map w titles, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) +
geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white") +
scale_fill_viridis_c(option = "D", trans = "log10") +
labs(x="Longitude",y="Latitude", title="Number of Electric Vehicle Charging Stations Per State", fill = "No. of Stations")
```
Feel free to edit the label names and the color option in the script to provide your own customizations. Next you need to add a scale bar and north arrow. To view the available options for the north arrow type ```northSymbols()``` into a new code block. The numeric values below each symbol will be used in the script to identify the specific style you choose. Because the north arrow, ```north```, is specifically related to the map data you need to provide the following arguments:
- dataset
- symbol, identified by the numerical value from ```northSymbols()```
- location, indicating where to base the location on the map
- anchor, coordinates for the symbol position on the map (based off the location)
- scale, the symbol size as a proportion of the map size
So your new script will look like:
```{r map titles north, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) +
geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white") +
scale_fill_viridis_c(option = "D", trans = "log10") +
labs(x="Longitude",y="Latitude", title="Number of Electric Vehicle Charging Stations Per State", fill = "No. of Stations") +
north(states, location = "bottomleft", scale = 0.05, symbol = 12, anchor = c(x= -70, y= 25))
```
In this example, ```location = "bottomleft"``` means the location of the _north arrow_ will be based from the bottom left of the symbol and ``anchor = c(x = -70, y = 25)``` is the geographic location on the map to draw the symbol. For example, if the _anchors_ were set at -100 and 40 the symbol would be draw on the Nebraska/Kansas border. Feel free to adjust the anchor points to draw the north arrow in your preferred location.
Now you need to add a scale bar. Many of the arguments used for the north arrow are duplicated for ```scalebar```
- dataset
- location, indicating where to base the location on the map
- anchor, coordinates for the symbol position on the map (based off the location)
- distance for each unit of the scale bar
- unit of measurement such as mi, km, etc.
- transform (TRUE/FALSE), assumes the coordinates are in decimal degrees
- model, choice of ellipsoid; which will be discussed later in the semester
- st.size, scale bar size
- st.dist, distance between the scale bar and the scale bar’s text, as a proportion of the y axis
```{r map titles north scale, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) +
geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white") +
scale_fill_viridis_c(option = "D", trans = "log10") +
labs(x="Longitude",y="Latitude", title="Number of Electric Vehicle Charging Stations Per State", fill = "No. of Stations") +
north(states, location = "bottomleft", scale = 0.05, symbol = 12, anchor = c(x= -70, y= 25)) +
scalebar(states, dist = 250, dist_unit = "mi", transform = TRUE, model = "WGS84", location = "bottomleft", st.dist = 0.05, st.size = 2, anchor = c(x=-125,y=27))
```
As with all of the other customizations above, feel free to adjust the units, distance, text distance, and size based on your own style.
Finally, you will need to add text to the map to indicate the name of the person who created the map and the date. In the future you will possibly include references or other text based information. There are a number of different ways you will explore for adding text information to your maps, such as ```caption = ``` in labs, but for this example you will use ```annotate()```. Similar to the north arrow and scale bar, there will be a:
- _x_ and _y_ argument to set the location
- size to indicate the font size
- label for the text you wish to include; to create a character return to move text to a new line you should use "\\n" where you want the text to move to a new line
Your final script should now look similar to this:
```{r final map, echo=TRUE, message=FALSE, warning=FALSE}
ggplot(states) +
geom_polygon(aes(x=long, y=lat, group=group, fill = evs_count), color = "white") +
scale_fill_viridis_c(option = "D", trans = "log10") +
labs(x="Longitude",y="Latitude", title="Number of Electric Vehicle Charging Stations Per State", fill = "No. of Stations") +
north(states, location = "bottomleft", scale = 0.05, symbol = 12, anchor = c(x= -70, y= 25)) +
scalebar(states, dist = 250, dist_unit = "mi", transform = TRUE, model = "WGS84", location = "bottomleft", st.dist = 0.05, st.size = 2, anchor = c(x=-125,y=27)) +
annotate("text", x = -90, y = 25, label = "Chris Gentry\n August 2021", size = 2)
```
There is an exhaustive amount of modifications that can be applied to the map above, but for now you have the minimum information required to create a map of similar kinds of data. In future exercises you will use various function to customize the look of your maps.
<b><big>Question No. 3</big></b>
<blockquote>
How does the _dist = _ argument in the ```scalebar``` function relate specifically to the distance of the scale bar on your map? How would changing the value alter the appearance?
</blockquote>
</details>
## Step Four: Your Turn
After a rash of severe weather over the past few years the Montgomery County Emergency Management Agency has asked you to provide a map detailing the number of reported tornadoes in each Tennessee county over the past several decades. This information will be shared with neighboring counties in middle Tennessee as a part of severe weather education campaign designed to inform communities about the risk of tornadoes in the region. The map should include all of the elements included on your previous map of electric vehicle charging stations such as:
- Title
- Scale
- North Arrow
- Legend
- Name/Date of Cartographer
Software specific directions can be found for each step below. Please submit the answer to the questions you answered above as well as your final tornado map by the due date.
<details><summary><big>View directions in <b> [ArcGIS Pro]{style="color:#ff4500"} </b></span></big></summary>
This portion of the exercise is meant to reinforce the skills you learned in the first part of the lab. The steps to complete your final map will be to:
1. Download and unzip the tornadoes dataset
2. Create a new map project
3. Add the data to your layers
4. Use the symbology tab to color the counties by number of tornadoes (**tornado_co**)
5. Map the data including all the necessary elements added above
To begin this portion of the exercise you will need to download the [tornado dataset](https://github.com/chrismgentry/GIS1-Exercise-2/raw/main/Data/Shapefiles/tornado_data.zip). Remember you can use the pop-up tool or the attribute table to examine the information. When you have completed your map, click the _Share Tab_ and click _Layout_ to save your map.
<p align="center"><div class="zoom"><img src="Images/arcgis-image-save.png" alt="Export map as image" style="width:100%"></div></p>
You will have a new **Export** section on the right-side of the screen. In the _Properties_ options change the _File Type_ to _\*.jpg_. This will allow you to add it to your word document and be submitted at the end of this exercise. In _Name_ click the browse button <img src= "Images/arcgis-browse-button.png" alt="Browse button to save layout" width="20" height="20"> to save the layout. It will default to the project folder and you can provide a name to identify the file. When done click _Save_ in the browser window, leave the other options as the default setting, and **Export** at the bottom of the section.
<big><b>Question No. 4</b></big>
<blockquote>
Which county had the highest number of reported tornadoes?<br>
<small>Hint: Remember you can sort the data in any column by clicking on the column header.</small>
</blockquote>
</details>
<hr></hr>
<details><summary><big>View directions in <b> [QGIS]{style="color:#006400"} </b></span></big></summary>
This portion of the exercise is meant to reinforce the skills you learned in the first part of the lab. The steps to complete your final map will be to:
1. Download and unzip the tornadoes dataset
2. Create a new map project
3. Add the data to your layers
4. Use the symbology tab to color the counties by number of tornadoes (**tornado_co**)
5. Map the data including all the necessary elements added above
To begin this portion of the exercise you will need to download the [tornado dataset](https://github.com/chrismgentry/GIS1-Exercise-2/raw/main/Data/Shapefiles/tornado_data.zip). Remember you can use the identity tool or the attribute table to examine the information. When you have completed your map, click _Project > Export as Image..._ on PC or _Project > Import/Export > Export Map to Image..._ on macOS to save your map as a _\*.jpg_. This will allow you to add it to your word document and be submitted at the end of this exercise.
<p align="center"><img src="Images/qgis-image-save.png" alt="Export map as image" style="width:100%"></p>
<big><b>Question No. 4</b></big>
<blockquote>
Which county had the highest number of reported tornadoes?<br>
<small>Hint: Remember you can sort the data in any column by clicking on the column header.</small>
</blockquote>
</details>
<hr></hr>
<details><summary><big>View directions in <b> [R]{style="color:#6495ED"} </b></span></big></summary>
This portion of the exercise is meant to reinforce the skills you learned in the first part of the lab. The steps to complete your final map will be to:
1. Create an object from the tornadoes dataset
2. Obtain a dataset of Tennessee counties
3. Determine which columns can be used to ```merge``` the datasets
4. Map out the data using ```ggplot```
To begin this portion of the exercise you will need this URL to the comma delimited dataset:
https://raw.githubusercontent.com/chrismgentry/GIS1-Exercise-2/main/Data/tn_tornadoes.csv
This data represents the number of reported tornadoes in each county from 1950-2020. As in step one of the exercise, you can use the **<-** operator to create a new object and the ```read.csv()``` function with the link to the dataset to import the data. Remember you can use ```head()``` or ```str()``` to examine the information.
To obtain county information for the State of Tennessee you should use the following script:
```{r tennessee, echo = TRUE, message=FALSE, warning=FALSE}
tn <- map_data('county', region = "tennessee")
head(tn)
```
If you search for _map_data_ in the **ggplot2** [documentation](https://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf) you will find an example of a script used to isolate information for the State of Iowa that can be adapted for any state in the dataset. Remember when working with scripts, Google is your friend! All it requires is asking the correct question to find some example code online that can help guide you. There are numerous possible answers to the same problem so don't hesitate to try other methods.
Using the example code from step two, you will need to ```merge``` the two datasets into a new object based on a common variable such as <small><i>Hint...hint</i></small> county name.
Finally, by adapting the ```ggplot``` code in step four, you can map the information for _tornado_count_ for each county in Tennessee. In order to limit the scope of your map to just the state you should add the following script to your modified ```ggplot``` code from above:
```
coord_fixed(xlim = c(-90,-82), ylim = c(35, 37))
```
The ```coord_fixed()``` function limits the axes based on specified values. The values are based on the units of measure of the data. In this can you see where the **x axis** is limited (_xlim_) from -82° to -90° west longitude and the **y axis** is limited (_ylim_) from 35° to 37° north latitude. If you omit this script your map will likely have a "smashed" appearance. For creating maps in **R** it is generally advisable to set the _x_ and _y_ coordinates to ensure proper display of your data. Remember you will need to adjust the anchor points of your _name and date_ text, _north arrow_ and _scale bar_ to fit the current map view. Additionally, the _title_ and _legend text_ should also reflect the information depicted on your map.
<big><b>Question No. 4</b></big>
<blockquote>
Which county had the highest number of reported tornadoes?<br>
Type ```subset(tn_tornadoes, tornado_count == max(tornado_count))``` into a new code cell or use Google to search for a county map of Tennessee to determine county locations on your map.<br>
<small>Hint: Replace **tn_tornadoes** in the code above with the object you created by merging the tornado and counties datasets.</small>
</blockquote>
</details>
# The Write-Up
The Montgomery County Emergency Management Agency has asked you to provide a map detailing the number of reported tornadoes in each Tennessee county over the past several decades. Based on the map you create above, complete a lab write-up that addresses the following questions:
- Provide the names of the five (5) counties that recorded the most tornadoes during that time frame
- Describe which regions of Tennessee had the fewest reported tornadoes
- Inform MCEMA which metropolitan regions could be most impacted by future severe weather events
When complete, send a link to your _Colab Notebook_ or email the word document or PDF with answers to Questions 1-4 and your completed map.