Created
March 13, 2019 09:41
-
-
Save djnavarro/14847e9b928686c4686330e62d09597c 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(geojsonio) | |
library(here) | |
library(broom) | |
reload <- FALSE | |
if(reload) { | |
spdf <- geojson_read( | |
x = here("unsw_map", "worldgeo.json"), | |
what = "sp" | |
) | |
} | |
spdf_fortified <- tidy(spdf, region = "admin") | |
spdf_other <- tibble( | |
id = spdf$admin, | |
pop = spdf$pop_est | |
) | |
spdf_all <- full_join(spdf_fortified, spdf_other) | |
# Now I can plot this shape easily as described before: | |
pic <- ggplot() + | |
geom_polygon( | |
data = spdf_fortified, | |
mapping = aes( | |
x = long, | |
y = lat, | |
group = group, | |
color = pop, | |
fill = pop | |
), | |
show.legend = FALSE | |
) + | |
theme_void() + | |
coord_map() | |
plot(pic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment