Task Description

Exploring Walkability Through Street View and Computer Vision

This assignment is divided into three main sections.

In the first section, you will select two Census Tracts within Fulton and DeKalb Counties, GA — one that you believe is the most walkable and another that is the least walkable. You may choose any tracts within these two counties. If the area you want to analyze is not well represented by a single tract, you may select multiple adjacent tracts (e.g., two contiguous tracts as one “walkable area”). The definition of walkable is up to you — it can be based on your personal experience (e.g., places where you’ve had particularly good or bad walking experiences), Walk Score data, or any combination of criteria. After making your selections, provide a brief explanation of why you chose those tracts.

The second section is the core of this assignment. You will prepare OpenStreetMap (OSM) data, download Google Street View (GSV) images, and apply the computer vision technique covered in class — semantic segmentation.

In the third section, you will summarize and analyze the results. After applying computer vision to the images, you will obtain pixel counts for 19 different object categories. Using the data, you will:

  • Create maps to visualize the spatial distribution of these objects,
  • Draw boxplots to compare their distributions between the walkable and unwalkable tracts, and
  • Perform t-tests to examine the differences in mean values and their statistical significance.

Section 0. Packages

Importing the necessary packages is part of this assignment. Add any required packages to the code chunk below as you progress through the tasks.

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tmap)
library(sf)
## Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(tidycensus)
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(sfnetworks)
library(tidygraph)
## 
## Attaching package: 'tidygraph'
## 
## The following object is masked from 'package:stats':
## 
##     filter
library(ggplot2)
library(broom)
library(knitr)
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows

Section 1. Choose your Census Tracts.

Use the Census Tract map in the following code chunk to identify the GEOIDs of the tracts you consider walkable and unwalkable.

# TASK ////////////////////////////////////////////////////////////////////////
# Set up your api key here
census_api_key(
  Sys.getenv("CENSUS_API_KEY")
)
# //TASK //////////////////////////////////////////////////////////////////////

# =========== NO MODIFICATION ZONE STARTS HERE ===============================
# Download Census Tract polygon for Fulton and DeKalb
tract <- get_acs("tract", 
                 variables = c('pop' = 'B01001_001'),
                 year = 2023,
                 state = "GA", 
                 county = c("Fulton", "DeKalb"), 
                 geometry = TRUE)

tmap_mode("view") #Because of update, I changed code from tm_mode to tmap_mode
tm_basemap("OpenStreetMap") +
  tm_shape(tract) + 
  tm_polygons(fill_alpha = 0.2)
# =========== NO MODIFY ZONE ENDS HERE ========================================

Once you have the GEOIDs, create two Census Tract objects – one representing your most walkable area and the other your least walkable area.

# TASK ////////////////////////////////////////////////////////////////////////
# 1. Specify the GEOIDs of your walkable and unwalkable Census Tracts. 
#    e.g., tr_id_walkable <- c("13121001205", "13121001206")
# 2. Extract the selected Census Tracts using `tr_id_walkable` and `tr_id_unwalkable`

# For the walkable Census Tract(s)
tr_id_walkable <- c("13121001205", "13121001206")

tract_walkable <- tract %>% 
  filter(GEOID %in% tr_id_walkable)

# For the unwalkable Census Tract(s)
tr_id_unwalkable <- c("13121002300", "13121011802")

tract_unwalkable <- tract %>% 
  filter(GEOID %in% tr_id_unwalkable)

# //TASK //////////////////////////////////////////////////////////////////////


# TASK ////////////////////////////////////////////////////////////////////////
# Create an interactive map showing `tract_walkable` and `tract_unwalkable`

tmap_mode("view")
tm_shape(tract_walkable) +
  tm_polygons(fill = "red",  fill_alpha = 0.5,
              col = "black", lwd = 2) +
tm_shape(tract_unwalkable) +
  tm_polygons(fill = "blue", fill_alpha = 0.5,
              col = "black", lwd = 2) +
tm_title("Chosen Tracts", size = 1.2) +
tm_add_legend(
  title  = "Legend",
  type   = "polygons",
  labels = c("Walkable", "Unwalkable"),
  fill   = c("red", "blue")
) +
tm_legend(
  outside    = FALSE,
  position   = c("right", "bottom"),
  title.size = 1.0,
  text.size  = 0.8
) +
tm_view(set_view = c(zoom = 13))
# //TASK //////////////////////////////////////////////////////////////////////

Provide a brief description of your selected Census Tracts. Why do you consider these tracts walkable or unwalkable? What factors do you think contribute to their walkability?

####Midtown Area:
This area is considered highly walkable because it has a relatively high Walk Score and well-developed sidewalk infrastructure. Pedestrian pathways are continuous and well-maintained, making it convenient and safe for walking.

####Bankhead Area:
This tract is considered less walkable, as it has a relatively low Walk Score. Limited sidewalk coverage and fewer pedestrian-friendly amenities likely contribute to its lower level of walkability.

Section 2. OSM, GSV, and Computer Vision.

Step 1. Get and clean OSM data.

To obtain the OSM network for your selected Census Tracts: (1) Create bounding boxes. (2) Use the bounding boxes to download OSM data. (3) Convert the data into an sfnetwork object and clean it.

# TASK ////////////////////////////////////////////////////////////////////////
# Create one bounding box (`tract_walkable_bb`) for your walkable Census Tract(s) and another (`tract_unwalkable_bb`) for your unwalkable Census Tract(s).

# For the walkable Census Tract(s)
tract_walkable_bb <- tract_walkable %>% 
  st_bbox()


# For the unwalkable Census Tract(s)  
tract_unwalkable_bb <- tract_unwalkable %>% 
  st_bbox()

# //TASK //////////////////////////////////////////////////////////////////////


# =========== NO MODIFICATION ZONE STARTS HERE ===============================
# Get OSM data for the two bounding boxes
osm_walkable <- opq(bbox = tract_walkable_bb) %>%
  add_osm_feature(key = 'highway', 
                  value = c("primary", "secondary", "tertiary", "residential")) %>%
  osmdata_sf() %>% 
  osm_poly2line()

osm_unwalkable <- opq(bbox = tract_unwalkable_bb) %>%
  add_osm_feature(key = 'highway', 
                  value = c("primary", "secondary", "tertiary", "residential")) %>%
  osmdata_sf() %>% 
  osm_poly2line()
# =========== NO MODIFY ZONE ENDS HERE ========================================


# TASK ////////////////////////////////////////////////////////////////////////
# 1. Convert `osm_walkable` and `osm_unwalkable` into sfnetwork objects (as undirected networks),
# 2. Clean the network by (1) deleting parallel lines and loops, (2) creating missing nodes, and (3) removing pseudo nodes (make sure the `summarise_attributes` argument is set to 'first' when doing so).

net_walkable <- osm_walkable$osm_lines %>% 
  # Drop redundant columns 
  select(osm_id, highway) %>% 
  sfnetworks::as_sfnetwork(directed = FALSE) %>% 
  activate("edges") %>%
  filter(!edge_is_multiple()) %>% # remove duplicated edges
  filter(!edge_is_loop()) %>% # remove loops
  convert(., sfnetworks::to_spatial_subdivision) %>% # subdivide edges
  convert(., sfnetworks::to_spatial_smooth, summarise_attributes = "first") # delete pseudo
## Warning: to_spatial_subdivision assumes attributes are constant over geometries
net_unwalkable <- osm_unwalkable$osm_lines %>% 
  # Drop redundant columns 
  select(osm_id, highway) %>% 
  sfnetworks::as_sfnetwork(directed = FALSE) %>% 
  activate("edges") %>%
  filter(!edge_is_multiple()) %>% # remove duplicated edges
  filter(!edge_is_loop()) %>% # remove loops
  convert(., sfnetworks::to_spatial_subdivision) %>% # subdivide edges
  convert(., sfnetworks::to_spatial_smooth, summarise_attributes = "first") # delete pseudo
## Warning: to_spatial_subdivision assumes attributes are constant over geometries
# //TASK //////////////////////////////////////////////////////////////////////
  
  
# TASK //////////////////////////////////////////////////////////////////////
# Using `net_walkable` and`net_unwalkable`,
# 1. Activate the edge component of each network.
# 2. Create a `length` column.
# 3. Filter out short (<300 feet) segments.
# 4. Randomly Sample 100 rows per road type.
# 5. Assign the results to `edges_walkable` and `edges_unwalkable`, respectively.

# OSM for the walkable part
set.seed(321)
edges_walkable <- net_walkable %>% 
  st_as_sf("edges") %>% 
  mutate(length = st_length(.) %>% unclass()) %>% 
  filter(length >= 91) %>% # Drop short segments (< 300 feet) #TEST
  group_by(highway) %>% 
  slice_sample(n = 100) %>%  # Sample 100 rows per road type
  ungroup() # Assign a unique ID for each edge

# OSM for the unwalkable part
edges_unwalkable <- net_unwalkable %>% 
  st_as_sf("edges") %>% 
  mutate(length = st_length(.) %>% unclass()) %>% 
  filter(length >= 91) %>% # Drop short segments (< 300 feet)
  group_by(highway) %>% 
  slice_sample(n = 100) %>%  # Sample 100 rows per road type
  ungroup() # Assign a unique ID for each edge

# //TASK //////////////////////////////////////////////////////////////////////

# =========== NO MODIFICATION ZONE STARTS HERE ===============================
# Merge the two
edges <- bind_rows(edges_walkable %>% mutate(is_walkable = TRUE), 
                   edges_unwalkable %>% mutate(is_walkable = FALSE)) %>% 
  mutate(edge_id = seq(1,nrow(.)))
# =========== NO MODIFY ZONE ENDS HERE ========================================

Step 2. Define getAzimuth() function.

In this assignment, you will collect two GSV images per road segment, as illustrated in the figure below. To do this, you will define a function that extracts the coordinates of the midpoint and the azimuths in both directions.

If you can’t see this image, try changing the markdown editing mode from ‘Source’ to ‘Visual’ (you can find the buttons in the top-left corner of this source pane).

getAzimuth <- function(line){

  # TASK ////////////////////////////////////////////////////////////////////////
  # 1. Use the `st_line_sample()` function to sample three points at locations 0.48, 0.5, and 0.52 along the line. These points will be used to calculate the azimuth.
  # 2. Use `st_cast()` function to convert the 'MULTIPOINT' object into a 'POINT' object.
  # 3. Extract coordinates using `st_coordinates()`.
  # 4. Assign the coordinates of the midpoint to `mid_p`.
  # 5. Calculate the azimuths from the midpoint in both directions and save them as `mid_azi_1` and `mid_azi_2`, respectively.
  
  # 1-3
  mid_p3 <- line %>% 
    st_line_sample(sample = c(0.48, 0.5, 0.52)) %>% 
    st_cast("POINT") %>% 
    st_coordinates()
  
  # 4
  mid_p <- mid_p3[2,]
  
  # 5
  mid_azi_1 <- atan2(mid_p3[1,"X"] - mid_p3[2, "X"],
                     mid_p3[1,"Y"] - mid_p3[2, "Y"])*180/pi
  
  mid_azi_2 <- atan2(mid_p3[3,"X"] - mid_p3[2, "X"],
                     mid_p3[3,"Y"] - mid_p3[2, "Y"])*180/pi
  
  # //TASK //////////////////////////////////////////////////////////////////////
 
  
  # =========== NO MODIFICATION ZONE STARTS HERE ===============================
  return(tribble(
    ~type,    ~X,            ~Y,             ~azi,
    "mid1",    mid_p["X"],   mid_p["Y"],      mid_azi_1,
    "mid2",    mid_p["X"],   mid_p["Y"],      mid_azi_2,))
  # =========== NO MODIFY ZONE ENDS HERE ========================================

}

Step 3. Apply the function to all street segments

Apply the getAzimuth() function to the edges object. Once this step is complete, your data will be ready for downloading GSV images.

# TASK ////////////////////////////////////////////////////////////////////////
# Apply getAzimuth() function to all edges.
# Remember that you need to pass edges object to st_geometry() before you apply getAzimuth()
edges_azi <- edges %>% 
  st_geometry() %>% 
  map_df(getAzimuth, .progress = T)

# //TASK //////////////////////////////////////////////////////////////////////

# =========== NO MODIFICATION ZONE STARTS HERE ===============================
edges_azi <- edges_azi %>% 
  bind_cols(edges %>% 
              st_drop_geometry() %>% 
              slice(rep(1:nrow(edges),each=2))) %>% 
  st_as_sf(coords = c("X", "Y"), crs = 4326, remove=FALSE) %>% 
  mutate(img_id = seq(1, nrow(.)))
# =========== NO MODIFY ZONE ENDS HERE ========================================

Step 4. Define a function that formats request URL and download images.

getImage <- function(iterrow){
  # This function takes one row of `edges_azi` and downloads GSV image using the information from the row.
  
  # TASK ////////////////////////////////////////////////////////////////////////
  # 1. Extract required information from the row of `edges_azi`
  # 2. Format the full URL and store it in `request`. Refer to this page: https://developers.google.com/maps/documentation/streetview/request-streetview
  # 3. Format the full path (including the file name) of the image being downloaded and store it in `fpath`
  type <- iterrow$type
  location <- paste0(iterrow$Y %>% round(5), ",", iterrow$X %>% round(5))
  heading <- iterrow$azi %>% round(1)
  edge_id <- iterrow$edge_id
  img_id <- iterrow$img_id
  key <- Sys.getenv("GOOGLE_API_KEY")
  
  endpoint <- "https://maps.googleapis.com/maps/api/streetview"
  
  request <- glue::glue("{endpoint}?size=640x640&location={location}&heading={heading}&fov=90&pitch=0&key={key}")
  fname <- glue::glue("GSV-nid_{img_id}-eid_{edge_id}-type_{type}-Location_{location}-heading_{heading}.jpg") # Don't change this code for fname
  fpath <- file.path("GSVimages_2", fname)
  # //TASK //////////////////////////////////////////////////////////////////////

  
  
  # =========== NO MODIFICATION ZONE STARTS HERE ===============================
  # Download images
  if (!file.exists(fpath)){
    download.file(request, fpath, mode = 'wb') 
  }
  # =========== NO MODIFY ZONE ENDS HERE ========================================
}

Step 5. Download GSV images

Before you download GSV images, make sure the row number in edges_azi is not too large! Each row corresponds to one GSV image, so if the row count exceeds your API quota, consider selecting different Census Tracts.

You do not want to run the following code chunk more than once, so the code chunk option eval=FALSE is set to prevent the API call from executing again when knitting the script.

# =========== NO MODIFICATION ZONE STARTS HERE ===============================
#for (i in seq(1,nrow(edges_azi))){
  #getImage(edges_azi[i,])
#}
# =========== NO MODIFY ZONE ENDS HERE ========================================

ZIP THE DOWNLOADED IMAGES AND NAME IT ‘gsv_images.zip’ FOR STEP 6.

Step 6. Apply computer vision

Use this Google Colab script to apply the pretrained semantic segmentation model to your GSV images.

Step 7. Merging the processed data back to R

Once all of the images are processed and saved in your Colab session as a CSV file, download the CSV file and merge it back to edges_azi.

# TASK ////////////////////////////////////////////////////////////////////////
# Read the downloaded CSV file containing the semantic segmentation results.
seg_output <- read.csv("GSVimages_2/seg_output_maj2.csv")

# //TASK ////////////////////////////////////////////////////////////////////////

# TASK ////////////////////////////////////////////////////////////////////////  
# 1. Join the `seg_output` data to `edges_azi`.
# 2. Calculate the proportion of predicted pixels for the following categories: `building`, `sky`, `road`, and `sidewalk`. If there are other categories you are interested in, feel free to include their proportions as well.
# 3. Calculate the proportion of greenness using the `vegetation` and `terrain` categories.
# 4. Calculate the building-to-street ratio. For the street, use `road` and `sidewalk` pixels; including `car` pixels is optional.

edges_seg_output <- edges_azi %>% 
  inner_join(seg_output, by=c("img_id"="img_id")) %>% 
  mutate(pct_building = building/(768*768),
         pct_sky = sky/(768*768),
         pct_road = road/(768*768),
         pct_sidewalk = sidewalk/(768*768),
         pct_vegetation = vegetation/(768*768),
         pct_terrain = terrain/(768*768),
         pct_car = car/(768*768),
         pct_greenness  = (vegetation+terrain)/(768*768),
         building_to_street_ratio = building / (road + sidewalk + car)
         )
  
# //TASK ////////////////////////////////////////////////////////////////////////

Section 3. Summarize and analyze the results.

At the beginning of this assignment, you specified walkable and unwalkable Census Tracts. The key focus of this section is the comparison between these two types of tracts.

Analysis 1 - Visualize Spatial Distribution

Create interactive maps showing the proportion of sidewalk, greenness, and the building-to-street ratio for both walkable and unwalkable areas. In total, you will produce 6 maps. Provide a brief description of your findings.

# TASK ////////////////////////////////////////////////////////////////////////
# Plot interactive map(s)
# As long as you can deliver the message clearly, you can use any format/package you want.

## Sidewalk
edges_walk_map  <- edges_seg_output %>% filter(is_walkable)
edges_unwalk_map <- edges_seg_output %>% filter(!is_walkable)

tm_basemap("OpenStreetMap") +
  tm_shape(edges_walk_map) +
  tm_dots(size = 0.7,
          fill = "pct_sidewalk", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(5, "YlGn")
            )
          ) +
  tm_title("Sidewalk(%): Walkable")
tm_basemap("OpenStreetMap") +
  tm_shape(edges_unwalk_map) +
  tm_dots(size = 0.7,
          fill = "pct_sidewalk", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(5, "YlGn")
            )
          ) +
  tm_title("Sidewalk(%): Unwalkable")
## Greenness
tm_basemap("OpenStreetMap") +
  tm_shape(edges_walk_map) +
  tm_dots(size = 0.7,
          fill = "pct_vegetation", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(5, "Greens")
            )
          ) +
  tm_title("Greenness(%): Walkable")
tm_basemap("OpenStreetMap") +
  tm_shape(edges_unwalk_map) +
  tm_dots(size = 0.7,
          fill = "pct_vegetation", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(5, "Greens")
            )
          ) +
  tm_title("Greenness(%): Unwalkable")
## Building to street ratio
tm_basemap("OpenStreetMap") +
  tm_shape(edges_walk_map) +
  tm_dots(size = 0.7,
          fill = "building_to_street_ratio", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(7, "RdYlBu")
            )
          ) +
  tm_title("Building-to-Street Ratio: Walkable")
tm_basemap("OpenStreetMap") +
  tm_shape(edges_unwalk_map) +
  tm_dots(size = 0.7,
          fill = "building_to_street_ratio", 
          fill.scale = tm_scale(
            values = RColorBrewer::brewer.pal(7, "RdYlBu")
            )
          ) +
  tm_title("Building-to-Street Ratio: Unwalkable")
# //TASK //////////////////////////////////////////////////////////////////////

Analysis 2 - Boxplot

Create boxplots for the proportion of each category (building, sky, road, sidewalk, greenness, and any additional categories of interest) and the building-to-street ratio for walkable and unwalkable tracts. Each plot should compare walkable and unwalkable tracts. In total, you will produce 6 or more boxplots. Provide a brief description of your findings.

# TASK ////////////////////////////////////////////////////////////////////////
# Create boxplot(s) using ggplot2 package.

# Buildings
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = pct_building, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Building Proportion",
    title = "Building(%) by Walkability"
  )

# Sky
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = pct_sky, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Sky Proportion",
    title = "Sky(%) by Walkability"
  )

# Road
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = pct_road, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Road Proportion",
    title = "Road(%) by Walkability"
  )

# Sidewalk
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = pct_sidewalk, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Sidewalk Proportion",
    title = "Sidewalk(%) by Walkability"
  )

# Greenness
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = pct_vegetation, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Greenness Proportion",
    title = "Greenness(%) by Walkability"
  )

# Building-to-street ratio
edges_seg_output %>%
  ggplot() +
  geom_boxplot(
    aes(x = is_walkable, y = building_to_street_ratio, fill = is_walkable),
    color = "black"
  ) +
  scale_fill_brewer(palette = "Blues") +
  labs(
    x = "Is Walkable or Not",
    y = "Building-to-Street Ratio",
    title = "Building-to-Street(Ratio) by Walkability"
  )

# //TASK //////////////////////////////////////////////////////////////////////

Analysis 3 - Mean Comparison (t-test)

Perform t-tests on the mean proportion of each category (building, sky, road, sidewalk, greenness, and any additional categories of interest) as well as the building-to-street ratio between street segments in the walkable and unwalkable tracts. This will result in 6 or more t-test results. Provide a brief description of your findings.

# TASK ////////////////////////////////////////////////////////////////////////
# Perform t-tests and report both the differences in means and their statistical significance.
# As long as you can deliver the message clearly, you can use any format/package you want.

# Building
t_building <- t.test(pct_building ~ is_walkable, data = edges_seg_output)
# Sky
t_sky <- t.test(pct_sky ~ is_walkable, data = edges_seg_output)
# Road
t_road <- t.test(pct_road ~ is_walkable, data = edges_seg_output)
# Sidewalk
t_sidewalk <- t.test(pct_sidewalk ~ is_walkable, data = edges_seg_output)
# Greenness (vegetation + terrain)
t_greenness <- t.test(pct_greenness ~ is_walkable, data = edges_seg_output)
# Building-to-street ratio
t_btor <- t.test(building_to_street_ratio ~ is_walkable, data = edges_seg_output)

t_results <- bind_rows(
  tidy(t_building)  %>% mutate(Variable = "Building(%)"),
  tidy(t_sky)       %>% mutate(Variable = "Sky(%)"),
  tidy(t_road)      %>% mutate(Variable = "Road(%)"),
  tidy(t_sidewalk)  %>% mutate(Variable = "Sidewalk(%)"),
  tidy(t_greenness) %>% mutate(Variable = "Greenness(%)"),
  tidy(t_btor)      %>% mutate(Variable = "Building-to-Street Ratio")
) %>%
  transmute(
    Variable,
    `Mean Diff (Unw - Walk)` = estimate,
    t = statistic,
    df = parameter,
    p_value = p.value,
    `95% CI Lower` = conf.low,
    `95% CI Upper` = conf.high
  ) %>%
  mutate(
    across(where(is.numeric), ~round(.x, 4))
  )

t_results |>
  kable(
    format = "html",
    booktabs = TRUE,
    align = c("l","r","r","r","r","r","r"),
    caption = "Welch t-tests: Unwalkable − Walkable"
  ) |>
  kable_styling(full_width = FALSE, bootstrap_options = c("striped","hover","condensed")) |>
  column_spec(2, width = "7em") |>
  column_spec(5, bold = TRUE) |>
  footnote(general = "Mean Diff = Unwalkable − Walkable; p-values are Welch t-tests.")
Welch t-tests: Unwalkable − Walkable
Variable Mean Diff (Unw - Walk) t df p_value 95% CI Lower 95% CI Upper
Building(%) -0.1764 -17.2408 153.3986 0.0000 -0.1966 -0.1562
Sky(%) 0.1441 14.2477 345.1841 0.0000 0.1242 0.1640
Road(%) 0.0130 1.7480 279.0035 0.0816 -0.0016 0.0275
Sidewalk(%) -0.0144 -4.6921 257.4639 0.0000 -0.0205 -0.0084
Greenness(%) 0.0414 2.9514 321.2540 0.0034 0.0138 0.0690
Building-to-Street Ratio -0.4873 -8.0699 139.7372 0.0000 -0.6066 -0.3679
Note:
Mean Diff = Unwalkable − Walkable; p-values are Welch t-tests.
# //TASK //////////////////////////////////////////////////////////////////////

T-test Results

The independent t-tests shows visual environmental differences between the walkable Midtown area and the less walkable Bankhead tract.

  • Building: Δ = −0.176 (t = −17.24, p < .001): Higher in Midtown (walkable).

  • Sidewalk: Δ = −0.014 (t = −4.69, p < .001): Higher in Midtown (walkable).

  • Building-to-Street Ratio: Δ = −0.487 (t = −8.07, p < .001): Higher in Midtown (walkable).

  • Sky: Δ = +0.144 (t = 14.25, p < .001): Higher in Bankhead (unwalkable).

  • Greenness: Δ = +0.041 (t = 2.95, p = .003): Higher in Bankhead (unwalkable).

  • Road: Δ = +0.013 (t = 1.75, p = .082): No significant difference.

Overall, Midtown exhibits a greater share of built-up structures, wider sidewalks, and a higher building-to-street ratio, reflecting its well-developed pedestrian infrastructure. In contrast, Bankhead features more visible sky and greater greenness, indicating more open and less developed surroundings.

The difference in road proportion is small and not statistically significant (t = 1.75, p = 0.0816), indicating similar road coverage in both areas.

Taken together, these results indicate that walkable environments such as Midtown are characterized by denser building forms and extensive sidewalk networks, whereas less walkable areas like Bankhead appear more open, sparsely developed, and less side-walk coverage.