Last active
January 13, 2022 13:33
-
-
Save jmcastagnetto/6b1d0983cd5ffefa8bcf07caa003b983 to your computer and use it in GitHub Desktop.
Plot map of Peru's Commuting Zones and of its provinces as comparison
This file contains 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
# Using data from https://data.humdata.org/dataset/commuting-zones | |
library(tidyverse) | |
library(sf) | |
library(geodata) | |
library(patchwork) | |
peru_map <- gadm("Peru", level = 2, path = ".") %>% | |
st_as_sf() | |
csv <- "~/Downloads/data-for-good-at-meta-commuting-zones-july-2021.csv" | |
df <- read_csv(csv) | |
sf_df <- st_as_sf(df, wkt = "geometry") | |
peru <- sf_df %>% filter(country == "Peru") | |
peru_provs <- ggplot() + | |
geom_sf(data = peru_map, size = .2, color = "black", fill = NA) + | |
scale_x_continuous(limits = c(-82, -64)) + | |
scale_y_continuous(limits = c(-20, 0)) + | |
labs( | |
title = "Peru: Provinces" | |
) + | |
theme_void(20) | |
peru_commute <- ggplot() + | |
geom_sf(data = peru, size = .2, color = "blue", fill = NA) + | |
scale_x_continuous(limits = c(-82, -64)) + | |
scale_y_continuous(limits = c(-20, 0)) + | |
labs( | |
title = "Peru: Commuting Zones", | |
subtitle = "Source: Facebook Commuting Zones (HUMDATA)" | |
) + | |
theme_void(20) | |
peru_provs + peru_commute |
Author
jmcastagnetto
commented
Jan 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment