Mapping

The total length of the videos in this section is approximately 15 minutes.

You can also view all the videos in this section at the YouTube playlist linked here.

This lecture was created by Teresa Li '19, so that's whose voice you will hear.

Introducing GIS

Using GIS data is the most common way to map in any program. GIS (Geographic Information System) is a way to analyze data by organizing layers of information into visualization using maps. ArcGIS is a software that is most well-known for data mapping, but R can be a good resource because it is free.

Please download the R file below and run the code along with the videos. You should also download the starbucks and Boston population data sets, which you will need as you go along.

Opening and exploring GIS data

In the following video, we're going to be using data about Boston neighborhoods, which you can access here (the data currently posted may be updated from the version shown in the video). Make sure you download the shapefile. Once downloaded unzip the folder. You will notice that the folder contains several files all with different file extensions. We are mainly interested in the .shp file.

Note: If you are having trouble installing the package "rgdal", you may have to download the most recent version of R. This may require you to update your computer. You could also try this tutorial on a public computer or try requesting access to the Wellesley R server.

Note: There is an extra line of code in gis_data.R that you need in order to use the updated version of the shapefile that is currently on the site linked above. This line of code is not in the video but is clearly marked in the code.

Mapping.1. Opening GIS Data.mp4

Question 1: Which slot in the bos object contains the non-geographic data?

  • @polygons

  • @data

  • @lines

Show answer

@data

Subsetting

Mapping.2.Subsetting.mp4

Question 2: In what order do you have to add layers to the base map?

  • Any order

  • New layers, then base layer

  • Base layer, then new layers

Show answer

Base layer, then new layers

Adding points

Mapping.3.Adding Points.mp4

If you tried to run the code in the video above and no points were added to the plot, make sure that you ran line 16 of the downloaded code file. This line of code is necessary to reformat the current version of the data, which was updated after the video was made.

Question 3: What functions can you use to add noise to a variable? Check all that apply.

  • rnorm()

  • jitter()

Show answer

Either

Attribute joins

Mapping.4.Attribute Joins.mp4

Question 4: Which merge function should you use to join two datasets together?

  • left_join

  • inner_join

  • right_join

Show answer

left_join

Heatmaps

Mapping.5.Heatmaps.mp4

And that is all.