user3710004
user3710004

Reputation: 580

Tigris r package how to include both elementary and unified school districts

I'm trying to create a map of school districts across the country. The Tigris shapefiles package is extremely helpful, but in some cases school districts are missing. I realized this was because it was only showing unified school districts, not elementary or secondary school districts. For example, if you plot districts in California, you will see that the elementary districts are missing.

library(tigris)
library(sf)

ca_districts <- school_districts(cb = TRUE, state="CA", type="unified"))
ggplot(ca_districts) +
  geom_sf()

ca_districts_elem <- school_districts(cb = TRUE, state="CA", type="elementary")
ggplot(ca_districts_elem) + 
  geom_sf()

My question is, is there any way to show all districts without any blank spaces, using Tigris? I did find a shapefile online which included all the districts (https://nces.ed.gov/programs/edge/Geographic/DistrictBoundaries), but I like the fact that when I use this package, I don't have to go searching for the link to the shapefile every time.

Upvotes: 0

Views: 193

Answers (1)

user3710004
user3710004

Reputation: 580

My friend helped me find a solution: layer two maps on top of each other.

ca_elem_districts <- school_districts(state="CA",cb = TRUE, type="elementary") 

ca_un_districts <- school_districts(state="CA",cb = TRUE, type="unified") 

ggplot() + 
  geom_sf(data=ca_elem_districts, aes(fill=ALAND)) +
  geom_sf(data=ca_un_districts, aes(fill=ALAND))

There are still a few districts missing however even when I layer unified, elementary and secondary districts.

Upvotes: 0

Related Questions