Skip to content

Instantly share code, notes, and snippets.

@djnavarro
Created March 13, 2019 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djnavarro/14847e9b928686c4686330e62d09597c to your computer and use it in GitHub Desktop.
Save djnavarro/14847e9b928686c4686330e62d09597c to your computer and use it in GitHub Desktop.
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