I'm trying to make a graph of California based on zip codes because I have some data that are based on them. I've tried excel-geography to plot but they only plotted a portion of zip codes with confidence.
Recently, I learned a mapping package in R called Tigris, which has been awesome. Even though zip codes aren't technically geography, they still have them listed, but they only 2010 data. Here's what I've done:
zipcodes <- zctas(year = 2010, state = "CA")
zipcodes <- zipcodes %>% filter(ZCTA5CE10>90000 & ZCTA5CE10 <96162) #Range of CA zip codes.
plot(zipcodes$geometry)
But the map seems incomplete using the proper range.
I would like to get a map that's similar to the one produced in excel, but with more zip code coverages and aesthetic options. What are some suggestions in mapping using zip codes? I'm pretty new to spatial analysis and also open to learn about other packages if there's any. Thanks!
If you select cb = TRUE
and year = 2000
you will get complete coverage of the state:
library(tigris)
library(ggplot2)
zipcodes <- zctas(year = 2000, state = "CA", cb = TRUE)
ggplot() +
geom_sf(data = ca, fill = "gray90") +
geom_sf(data = zipcodes, aes(fill = AREA), linewidth = 0.1) +
scale_fill_gradientn(colors = c("red", "cornsilk", "#f0d080"),
values = c(0, 0.03, 1), guide = "none") +
theme_minimal()