Search Results for: pa census

Make Your Maps in QGIS but use R and Tidycensus to Generate Census Shapefiles πŸ—Ί

Make Your Maps in QGIS but use R and Tidycensus to Generate Census Shapefiles πŸ—Ί

Why choose when you can have it all? Seriously, QGIS makes it easy to move labels as you like and do the styling of the Shapefile or GeoPackage you generate in R with tidycensus and sf.

library(tidycensus)
library(sf)
lowincome <- get_acs(
  geography = “state”,
  table = ‘B19001’,
  year = 2020,
  output = ‘wide’,
  survey = “acs5”,
  geometry = TRUE);
lowincome$under30k <- ((lowincome$B19001_002E +lowincome$B19001_003E+ lowincome$B19001_004E+ lowincome$B19001_005E+ lowincome$B19001_006E) /lowincome$B19001_001E)*100
lowincome %>% write_sf(‘/tmp/under30k.gpkg’)

With the above R code, it will generate a GeoPackage (use extension .gpkg) or Shapefile (use extension .shp) you can use to make your map in QGIS. Then in QGIS if you want to simplify the output, you can use a geometry generator in the styles:

simplify($geometry,0.003)

Or you can specify the simplification in the R script when you run get_acs(), as it is a wrapper around the tigris package:

lowincome <- get_acs(
  geography = “state”,
  table = ‘B19001’,
  year = 2020,
  output = ‘wide’,
  survey = “acs5”,
  geometry = TRUE,
  resolution = ’20m’,
);

Neat ! R and QGIS are great tool to use together.

2020 Census Under Counts

2020 Census Under Counts

In 2020, there was a meme about the importance of New Yorkers being counted in the Census, so not to be under-counted as compared to Idaho. But when the Census Bureau took a final review of 2020 Census, it turns out New York over-counted by 3.44% or 695,000 residents while Idaho under-counted by 1.55% or 29,000 residents.
 
Southern States -- especially Texas and Florida had big under counts, it looks due to low participation rates of Hispanic voters, which the Census reports were under counted. Ultimately when the history books were finalized on the census, it was President Trump's messing around with the census that hurt red states more then blue states. Go figure.
 

 

R Programming – IDW interpolation of Missing / NA Census Tract Data

You can do IDW interpolation of missing Census Tracts fairly easily in R using the gstat library. The key is to make sure you use a projected dataset. Other interpolation methods are covered here: https://rspatial.org/raster/analysis/4-interpolation.html

library(tidycensus)
library(tidyverse)
library(raster)
library(gstat)

# obtain census data on veteran status by tract and then
# reproject the shapefile geometery into a projected coordinate system

acs <- get_acs("tract",
state='ny',
survey='acs5',
var=
c('Total'='B21001_001',
'Veteran'='B21001_002'
),
cache_table = T,
geometry = T,
resolution='20m',
year = 2020,
output = "wide"
) %>% st_transform(26918)

# calculate the percentage of veterans per census tract
acs <- mutate(acs, vet_per = VeteranE/TotalE)

# create a copy of census tracts, dropping any NA values
# from vet_per field
vetNA <- acs %>% drop_na(vet_per)

# a raster should be created to do interpolation into
r <- raster(vetNA, res=1000)


# set the foruma based on field (vet_per) that contains
# the veterans percent to interpolate. This use IDW interpolation
# for all points, weighting farther ones less
gs <- gstat(formula = vet_per~1, locations = vetNA)

# interpolate the data (average based on nearby points)
nn <- interpolate(r, gs)

# extract the median value of the raster interpolation from the original shapefile,
# into a new column set as est
acs<- cbind(acs, est=exactextractr::exact_extract(nn, acs, fun='median'))

# replace any NA values with interpolated data so the map doesn't contain
# holes. You should probably mention that missing data was interpolated when
# sharing your map.
acs <- acs %>% mutate(vet_per = ifelse(is.na(vet_per), est, vet_per))

Census-designated Urban Areas in New York State (2010)

Census-designated Urban Areas in New York State (2010)

  • 87.8 percent of New York's population lives in urban areas
  • 8.7 percent of New York's landmass is urban areas as of 2010

For the 2010 Census, an urban area will comprise a densely settled core of census tracts and/or census blocks that meet minimum population density requirements, along with adjacent territory containing non-residential urban land uses as well as territory with low population density included to link outlying densely settled territory with the densely settled core. To qualify as an urban area, the territory identified according to criteria must encompass at least 2,500 people, at least 1,500 of which reside outside institutional group quarters.

The Census Bureau identifies two types of urban areas:

Urbanized Areas (UAs) of 50,000 or more people;
Urban Clusters (UCs) of at least 2,500 and less than 50,000 people.

“Rural” encompasses all population, housing, and territory not included within an urban area.

2020 Urban - Rural areas will be released December 2022.

Renters vs Population Density – NY Census Tracts

Renters vs Population Density - NY Census Tracts

I was a bit surprised to see that there isn't a stronger correlation between population density and the percent of the population that rents. But maybe it's because often Census Tracts contains things besides residential properties like roads, parks, and businesses.