Created
August 4, 2016 20:08
-
-
Save walkerke/d9c778563ba9651e0b26f9bef32625df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(leaflet) | |
library(tigris) | |
library(sp) | |
compare_urban_metro <- function(metro_name) { | |
cbsa <- core_based_statistical_areas(cb = TRUE, resolution = '20m') | |
ua <- urban_areas(cb = TRUE) | |
dfw_cbsa <- cbsa[cbsa$NAME == metro_name, ] | |
o <- over(dfw_cbsa, ua, returnList = TRUE) | |
dfw_ua <- ua[ua$NAME10 %in% o[[1]]$NAME10, ] | |
leaflet() %>% | |
addTiles() %>% | |
addPolygons(data = dfw_cbsa) %>% | |
addPolygons(data = dfw_ua, color = 'red', fillColor = 'red') | |
} | |
compare_urban_metro("Dallas-Fort Worth-Arlington, TX") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment