Arctic regions geospatial wrangling

Week 7 - Discussion section

In this discussion section you will wrangle geospatial data about Arctic communities

Setup

  1. Access the workbench-1 server.

  2. Create a new Python notebook inside your eds-220-sections directory and rename it to section-7-arctic-communities.ipynb.

  3. Use the terminal to push this file to your remote repository.

General directions

  • Add comments as appropriate along your code following the course commenting standards.
  • Include markdown cells in between your code cells to add titles and information to each exercise
  • Commit every time you finish a major step. Remember to write informative commits in the imperative mood.

About the data

Arctic communities hold immense value in traditional knowledge and environmental stewardship, offering unique insights into sustainable practices and ecosystem management in one of the planet’s most extreme environments. For this section you will use a dataset derived from the list of Arctic communities and their location [1] created by the Alaska Native Tribal Health Consortium and Natural Earth’s medium-scale cultural boundaries data for countries (1:50m) following the procedure in the Reprojecting notes.

Image Source: Arctic Communities WWF. ©Staffan Widstrand/WWF.

The data is in the arctic_communities.geojson file located in the data/ directory for the EDS 220 class within workbench-1. Each geospatial feature in the data represents an Arctic territory with the following attributes:

Attribute Description
admin name of the territory
country two-letter code
n_communities number of Arctic communities in the territory

1. Data loading and exploration

Read in the data into a variable named df and examine it with your team.

2. Brainstorm

The goal of these exercises is to refine the Arctic communities choropleth map created in the Reprojecting lesson to restrict the plotting to the Arctic relevant regions:

  1. Individually, write down high-level steps on how you would explore and wrangle the data to produce the updated map. Do not code anything yet.

  2. Discuss your high-level steps with your team. What do you see as potential challenges to implementing your plan?

The next exercises will guide you through selecting relevant Arctic regions. There are many ways of doing this. The one presented here might not be the same way you thought about doing it - that’s ok! This one was designed to practice creating functions.

2. Check geometry types

  1. Run df.geom_type. Write a brief explanation about the output in a markdown cell.

  2. Create an if-else statement that:

    1. prints “All features are polygons.” if all the features in the df are polygons and

    2. prints “Multiple feature types:” followed by the unique geometry types (no repetition) in the geodataframe if not all the features are polygons.

  3. Wrap up your code into a function named check_polygons that receives a single geodataframe as its parameter and prints out a message stating whether all the geometry types are polygons or not.

3. Explode polygons

  1. Overwrite the df geodataframe with the output from the explode method with the index_parts parameter set to False. Read the documentation for the method and use a markdown cell to write a brief explanation of what is being done.

  2. Reset the index of df.

  3. Use your check_polygons function to verify that df only has features of type polygon.

Don’t forget to write informative commits in the imperative every time you finish a major step.

4. Compute minimum y-coordinate for polygons

At this point, every row in your df should be a single polygon.

  1. Select the first row of df using iloc. What kind of Python object is this?

  2. Select the geometry of the first row of df. What kind of Python object is this?

  3. Use the bounds attribute for shapely Polygons to select the southern-most bound of the first polygon in df.

  4. Create a function min_y that receives a single row of a geodataframe as its parameter and returns the minimum y-coordinate of its bounding box.

  5. Use the min_y function and the apply method for data frames to create a new column miny in df which has the minimum y coordinate.

6. Filter, update CRS, and reproduce map

  1. Select the polygons with a bounding box at or above 40 degrees of latitude into a new variable named arctic.

  2. Reproduce the Arctic communities map by updating the CRS to EPSG:3413.

References

[1]
M. Brook, “Approximate Arctic Communities and Populations, (latitude >= 55, 2022).” Arctic Data Center, 2023. doi: 10.18739/A28S4JQ80. Available: https://arcticdata.io/catalog/view/doi:10.18739/A28S4JQ80. [Accessed: Nov. 03, 2024]