TDM 20200: Mapping: Project 10 — Spring 2025

Motivation: We will now use our knowledge of plotting maps in Python.

Context: We will leverage what we know about several data sets, to make some maps.

Scope: Mapping

Learning Objectives:
  • We continue to learn how to make maps in Python

Make sure to read about, and use the template found here, and the important information about project submissions here.

Dataset(s)

In this project we will use the following mapping data:

  • /anvil/projects/tdm/data/nps/nps_boundary.shp

  • /anvil/projects/tdm/data/boundaries/cb_2018_us_state_20m.shp

  • /anvil/projects/tdm/data/aiannh/tl_2023_us_aiannh.shp

Questions

Load Pandas as Geopandas as follows:

import pandas as pd
import geopandas as gpd

Question 1 (2 pts)

Consider the flight data contained in the files from

/anvil/projects/tdm/data/flights/subset/1987.csv

through

/anvil/projects/tdm/data/flights/subset/2008.csv

Determine the total number of flights that departed from each Origin airport from 1987 to 2008, altogether.

You need the seventeenth column from each data set; since Python starts counting from 0, this is column 16. It is OK to look at TDM 10200 Project 10 Question 2 the-examples-book.com/projects/spring2025/10200/project10 where the students are practicing with the same data sets.

Deliverables
  • Determine the total number of flights that departed from each Origin airport from 1987 to 2008, altogether.

  • Be sure to document your work from Question 1, using some comments and insights about your work.

Question 2 (2 pts)

Once you have the total number of flights that departed from each Origin airport from 1987 to 2008, use the file from /anvil/projects/tdm/data/flights/subset/airports.csv to determine the total number of flights that departed from each of the 48 continental states (and DC). Then use the US state maps /anvil/projects/tdm/data/boundaries/cb_2018_us_state_20m.shp to plot the continential United States, with the top 10 states (according to the number of flights that departed from Origin airports in those states) portrayed in a distinct color, so that these 10 states are easily visible.

Deliverables
  • Plot the continential United States, with the top 10 states (according to the number of flights that departed from Origin airports in those states) portrayed in a distinct color, so that they are easily visible.

  • Be sure to document your work from Question 2, using some comments and insights about your work.

Question 3 (2 pts)

You can handle this question separately from Question 2; in other words, it is OK to make a totally new map for this question.

Using the file from /anvil/projects/tdm/data/flights/subset/airports.csv, which has latitude and longitude values, plot the locations of the 3376 aiports onto the map of the US /anvil/projects/tdm/data/boundaries/cb_2018_us_state_20m.shp (it is OK if you only want to focus on the 48 continental states and DC).

Deliverables
  • Plot the locations of the 3376 aiports onto the map of the US (or it is OK if you only want to focus on the 48 continental states and DC).

  • Be sure to document your work from Question 3, using some comments and insights about your work.

Question 4 (2 pts)

Consider the election data contained in the even-numbered years from

/anvil/projects/tdm/data/election/itcont1980.txt

through

/anvil/projects/tdm/data/election/itcont2024.txt

Determine the total amount of money given (in dollars) during election campaigns from 1980 to 2024, altogether.

You need the tenth and fifteenth columns from each data set; since Python starts counting from 0, these are columns 9 and 14. It is OK to look at TDM 10200 Project 10 Question 4 the-examples-book.com/projects/spring2025/10200/project10 where the students are practicing with the years from 1980 through 2018.

Deliverables
  • Determine the total amount of money given (in dollars) during election campaigns from 1980 to 2024, altogether.

  • Be sure to document your work from Question 4, using some comments and insights about your work.

Question 5 (2 pts)

Once you have the total amount of money donated from each state, use the US state maps /anvil/projects/tdm/data/boundaries/cb_2018_us_state_20m.shp to plot the continential United States, with the top 10 states (according to the number of donations) portrayed in a distinct color, so that these 10 states are easily visible.

Deliverables
  • Plot the continential United States, with the top 10 states (according to the number of donations) portrayed in a distinct color, so that they are easily visible.

  • Be sure to document your work from Question 5, using some comments and insights about your work.

Submitting your Work

Please make sure that you added comments for each question, which explain your thinking about your method of solving each question. Please also make sure that your work is your own work, and that any outside sources (people, internet pages, generating AI, etc.) are cited properly in the project template.

Congratulations! Assuming you’ve completed all the above questions, you are learning to apply your web scraping knowledge effectively!

Prior to submitting your work, you need to put your work into the project template, and re-run all of the code in your Jupyter notebook and make sure that the results of running that code is visible in your template. Please check the detailed instructions on how to ensure that your submission is formatted correctly. To download your completed project, you can right-click on the file in the file explorer and click 'download'.

Once you upload your submission to Gradescope, make sure that everything appears as you would expect to ensure that you don’t lose any points. We hope your first project with us went well, and we look forward to continuing to learn with you on future projects!!

Items to submit
  • firstname_lastname_project10.ipynb

It is necessary to document your work, with comments about each solution. All of your work needs to be your own work, with citations to any source that you used. Please make sure that your work is your own work, and that any outside sources (people, internet pages, generating AI, etc.) are cited properly in the project template.

You must double check your .ipynb after submitting it in gradescope. A very common mistake is to assume that your .ipynb file has been rendered properly and contains your code, markdown, and code output even though it may not.

Please take the time to double check your work. See here for instructions on how to double check this.

You will not receive full credit if your .ipynb file does not contain all of the information you expect it to, or if it does not render properly in Gradescope. Please ask a TA if you need help with this.