Mapping

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.

Largest Range In Elevation

Towns in the Eastern Adirondacks and Eastern Catskills have the greatest change in elevation in their borders. This is done with 100 meter digital elevation model, so this does not include peaks -- but a comparison of general height of land in one part of the town compared to another.

Data Source: 100 meter Digital Elevation Model of New York. CUGIR. https://cugir.library.cornell.edu/

 

Which is Closer – New York or Texas?

Which is Closer - New York or Texas?

I've been playing with st_nearest_feature in R/sf to calculate nearest features on a map.

ct <- counties(cb=T, resolution = '20m') %>% st_transform(5070)
st <- states(cb=T, resolution = '20m') %>% filter(NAME %in% c('Texas','New York')) %>% st_transform(5070)

nr <- st_nearest_feature(ct, st)

ct <- cbind(ct, st_drop_geometry(st)[nr,])