Population density changes in person per km2 in lowlands Ethiopia.
bins <- c(-100, -50, 0, 15, 50, 100, 150, 250, 280)
pal <- colorBin("PuOr", domain = df_pd$change_km2, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g person/km2",
df_pd$REGIONNAME, df_pd$WOREDANAME, round(df_pd$change_km2, 2)
) %>% lapply(htmltools::HTML)
m <- leaflet(df_pd) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(df_pd$change_km2),
weight = 1,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pal, values = df_pd$change_km2, opacity = 0.7, title = "Population density changes between 2000 and 2017 (person/km2)", position = "bottomright")
df_pd$total_ppl_changes <- (df_pd$mean_2017 - df_pd$mean_2000)*df_pd$count_2017
bins <- c(-191192.7, -100000, -500000, -50000, 0, 50000, 100000, 200000, 450000)
pal <- colorBin("Greens", domain = df_pd$total_ppl_changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g person",
df_pd$REGIONNAME, df_pd$WOREDANAME, round(df_pd$total_ppl_changes, 2)
) %>% lapply(htmltools::HTML)
m <- leaflet(df_pd) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(df_pd$total_ppl_changes),
weight = 1,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pal, values = df_pd$total_ppl_changes, opacity = 0.7, title = "Population density changes between 2000 and 2017", position = "bottomright")
palette <- brewer.pal(n = 9, name = "YlGnBu")
pd <- spplot(df_pd, c('pd_2000_km2', 'pd_2017_km2'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Population density (person/km2) in Ethiopia")
pd
## Woredas have the max population larger than 1000
df_large <- df_pd[df_pd$max_2017 >=1000,]