---
title: "{cincy} Geographies"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{{cincy} Geographies}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>", 
  echo = FALSE, 
  message = FALSE, 
  warning = FALSE
)
```

```{r setup}
library(cincy)
library(tmap)
library(sf)

d_tract <- st_transform(cincy::dep_index, 3735)
```

The `cincy` package provides commonly used Cincinnati geographies, including census tracts, neighborhoods, and ZIP Code Tabulation Areas, as `sf` objects.

## Census Tracts

Census tracts are small statistical [subdivisions](https://www2.census.gov/geo/pdfs/reference/geodiagram.pdf) of a county, each with an average population of about 4,000 (max: 1,200; min: 8,000), that are redefined every 10 years.
Census tracts are the most often used level of census geography at which the most precise American Community Survey data is available.

#### Hamilton County, OH

Below is a map of the (2010 vintage) census tracts in Hamilton County, Ohio colored relative to the estimated fraction of households in poverty. From 2010-2019 there were 222 census tracts in Hamilton County, but this number was 230 for 2000-2009 and 226 for 2020-2029. 

```{r}
#| fig-align: center
d_tract |> 
  tm_shape() +
  tm_polygons("fraction_poverty", 
              pal = "viridis", 
              style = "cont", 
              title = "Fraction Poverty", 
              breaks = seq(0, 1, 0.2)) +
  tm_layout(frame = FALSE,
            legend.text.size = 0.8,
            legend.outside = FALSE) +
  tm_scale_bar(text.size = 0.8, position = c("center", "BOTTOM"))
```

## Neighborhoods

Although census tracts approximate local neighborhoods, they are mostly based on population size and streets or other natural boundaries. Neighborhood boundaries can be defined in other ways that may be more appropriate in the context of policy changes or interventions. Below are three different neighborhood definitions in the Cincinnati area.

- **Cincinnati Community Council (CCC) Neighborhoods**: Cincinnati Community Council neighborhood definitions for neighborhoods within the Cincinnati city limits
- **Statistical Neighborhood Approximations (SNA) Neighborhoods**: Created by matching census tract boundaries to the Community Council boundaries as closely as possible
- **Tract Boundary-Based Neighborhoods**: Expansion of neighborhood boundaries to include all neighborhoods within the county
	
#### Tract Boundary-Based Neighborhoods

Below is a map of the (2010 vintage) tract boundary-based neighborhoods in Hamilton County, Ohio colored relative to the estimated fraction of households in poverty.

```{r}
#| fig-align: center
d_tract |>
  cincy::interpolate(to = cincy::neigh_cchmc_2010, weights = "area") |>
  st_transform(3735) |>
  tm_shape() +
  tm_polygons("fraction_poverty", 
              pal = "viridis", 
              style = "cont", 
              title = "Fraction Poverty", 
              breaks = seq(0, 1, 0.2)) +
  tm_layout(frame = FALSE,
            legend.text.size = 0.8,
            legend.outside = FALSE) +
  tm_scale_bar(text.size = 0.8, position = c("center", "BOTTOM"))
```

## ZIP Codes

Zone Improvement Plan (ZIP) codes are often used for place-based data because matching them to a mailing address doesn't require geocoding and spatial linkage; however, using ZIP codes can cause substantial scientific problems.

ZIP codes are continuously defined and redefined over time as collections of different streets by the US Postal Service.  They change frequently and do not have defined zonal boundaries, but the US Census Bureau developed the ZIP code tabulation area (ZCTA) product as a way to aggregate census data and link them to ZIP codes.
The area of both ZCTAs and ZIP codes varies widely with some representing over 10,000 sq. mi. of land area but other representing densely populated areas as small as 2 city blocks. The population is similarly variable with an average population of about 10,000 but many ZIP codes representing less than 1,000 and even less than 100 individuals. 

Unlike nearly all other census geographies, ZCTAs are not based on population or contextual neighborhood boundaries, but rather on the location of delivery post offices. Millions of Americans currently use a mailing address that corresponds to a neighboring town, village, or neighborhood where they receive their mail from, instead of the jurisdiction where they actually live. ZIP Codes do not always properly represent the environment of their inhabitants, and spatial analyses utilizing ZIP Codes have misled place-based health researchers. One notable example is the recent Flint drinking water crisis, where the misalignment of ZIP boundaries with the municipal boundaries of the City of Flint, Michigan caused researchers and public health officials to initially conclude that increased blood lead levels were not due to drinking water contamination.

#### Hamilton County, OH ZCTAs

Below is a map of the (2010 vintage) ZCTAs in Hamilton County, Ohio colored relative to the estimated fraction of households in poverty. 

```{r}
#| fig-align: center
d_tract |>
  cincy::interpolate(to = cincy::zcta_tigris_2010, weights = "area") |>
  st_transform(3735) |>
  tm_shape() +
  tm_polygons("fraction_poverty", 
              pal = "viridis", 
              style = "cont", 
              title = "Fraction Poverty", 
              breaks = seq(0, 1, 0.2)) +
  tm_layout(frame = FALSE,
            legend.text.size = 0.8,
            legend.outside = FALSE) +
  tm_scale_bar(text.size = 0.8, position = c("center", "BOTTOM"))
```

## Comparing Geographies

See the [vignette on Avondale](vignettes/geographies.html) for a detailed case study on the impacts of using these different geographies to estimate neighborhood-level characteristics.

See [two linked, interactive maps that can be used for side-by-side investigation of different {cincy} geography types and vintages](http://cincy-comparing-geographies.s3-website-us-east-1.amazonaws.com/).

## References

<https://www2.census.gov/geo/pdfs/education/CensusTracts.pdf>

<https://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html>

<https://www.cincinnati-oh.gov/sites/planning/assets/File/Statistical%20Neighborhood%20Approximations%20Map.pdf>
