Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.