Neighborhood Analysis
  • Home
  • Syllabus
  • Schedule
  • Assignments
  • How To
  • Resources
  • Discussion
  1. Strategies for Analysis
  2. 13. Segregation
  • Schedule Overview
    • Course Schedule
  • Course Introduction
    • 1. Course Introduction
    • 2. What is a Neighborhood?
    • 3. Building a Data Pipeline
    • 4. Working with Tidy Data
    • 5. Working with Tidy Data
    • 6. Describing Places
    • 7. Communicating Complex Information
  • Strategies for Analysis
    • 8. Describing Places
    • 9. Describing Places
    • 10. Population and the Census
    • 11. Population and the Census
    • 12. Segregation
    • 13. Segregation
    • 14. Neighborhood Change
    • 15. Neighborhood Change
    • 16. Place Opportunity
    • 17. Place Opportunity
    • 18. Transit Equity
    • 19. Transit Equity
    • 20. Health Equity
    • 21. Health Equity
    • 22. Final Project Check-In
    • 23. Final Project Check-In
  • Course Wrap-Up
    • 24. Field Observation
    • 25. Field Observation
    • 26. Final Presentations
    • 27. Independent Work and Advising
    • 28. Final Presentations
    • 29. Final Presentations

On this page

  • Session Description
  • Before Class
  • Reflect
  • Code
    • Option 1: Spatial Join
    • Option 2: Intersection
  • Slides
  • Resources for Further Exploration

Segregation

Session Description

In this session, we will begin to work on a lab focused on measures of residential segregation. We will also spend some time workshopping your approach to the Population Memo.

We’ll take around 20 minutes at the beginning of class for you to share with each other what you’re thinking and your approach.

We’ll then engage any questions you have about this week’s lab or last week’s lab.

Before Class

GitHub Classroom Link

Please come ready to share your approach to the population memo in small groups. Please bring in examples of analysis or visualization that we can look at, either in small groups or collectively.

Reflect

Code

In class, we spent some time looking at code that would select tracts within census place geographies. Here’s that code for your reference.

Let’s start by downloading tract and place geometries and selecting Chicago (as an example):

First, download tracts, subset to Cook County, and plot to confirm:

library(sf)
library(tigris)
library(tidyverse)


il_trt <- tracts(state = "IL") |> 
  filter(COUNTYFP == "031")

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
ggplot()+
  geom_sf(data = il_trt) 

Next, download census place boundaries, filter to Chicago, and plot to confirm:

il_place <- places(state = "IL") |> 
  filter(NAME == "Chicago")

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |======================================================================| 100%
ggplot()+
  geom_sf(data = il_place, cex = 1) 

Plot together to see overlay:

ggplot()+
  geom_sf(data = il_trt, cex=.1)+
  geom_sf(data = il_place, color = "blue",cex = .5, fill = NA)

Option 1: Spatial Join

Perform a spatial join to identify all tracts that overlap with Chicago’s municipal boundaries, plot to confirm:

test <- st_join(il_trt, il_place) |> 
  filter(NAME.y == "Chicago")

ggplot() +
  geom_sf(data = test) +
  geom_sf(data = il_place, color = "blue", fill = NA)

Option 2: Intersection

Another option is to find the spatial intersection of the two objects:

test2 <- st_intersection(il_trt, il_place)

ggplot() +
  geom_sf(data = test2)+
  geom_sf(data = il_place, color = "blue", fill = NA)

As we discussed in class, there may be good reasons for pursuing either method. Intersection may produce visually “cleaner” output, but we may need to spend more time explaining that there are portions of tract geometry that fall outside of the city boundary. We may even want to do some analysis to estimate where uncertainty may come from due to our strategy.

Slides

Resources for Further Exploration

Content Andrew J. Greenlee
 
Made with and Quarto
Website Code on Github