Any spatial dataframe you create in R, such as with tidycensus can be exported with write_sf to a shapefile

Any spatial dataframe you create in R, such as with tidycensus can be exported with write_sf to a shapefile.

I know this isn’t rocket science but it is a big time and headache saver. Sometimes joins don’t go quite right in QGIS due to your own silliness but if obtain the spatial data right at the same time as Census data using tidycensus geometry=True then you don’t have to manually join the data, deal with type issues or the wrong year TIGER line.

For example for the PA Poverty maps I poste on the Facebook:

library(tidycensus)
library(sf)

income <- get_acs(
geography = 'tract',
variables = 'S1701_C03_001',
state = 'PA',
geometry = T)

write_sf(income,'/tmp/pa_poverty.shp')

Leave a Reply

Your email address will not be published. Required fields are marked *