df_nl <- urban_2000
df_nl$mean_2000 <- df$mean
df_nl$mean_2017 <- df$mean_2017
df_nl$mean_2000 <- df_nl$mean_2000 /10
df_nl$mean_2017 <- df_nl$mean_2017 / 10
df_1 <- df[,c("OBJECTID", "REGIONNAME", "WOREDANAME", "area_ha", "mean", "mean_2001", "mean_2002", "mean_2003", "mean_2004", "mean_2005", "mean_2006", "mean_2007", "mean_2008", "mean_2009", "mean_2010", "mean_2011", "mean_2012", "mean_2013", "mean_2014", "mean_2015", "mean_2016", "mean_2017")]
nl_cols <- c("mean", "mean_2001", "mean_2002", "mean_2003", "mean_2004", "mean_2005", "mean_2006", "mean_2007", "mean_2008", "mean_2009", "mean_2010", "mean_2011", "mean_2012", "mean_2013", "mean_2014", "mean_2015", "mean_2016", "mean_2017")
df_nl$changes <- df_nl$mean_2017 - df_nl$mean_2000
df_nl$changes <- round(df_nl$changes, 3)
#df_nl[, df_nl %in% nl_cols >= 63]<- 60
#cols <- c('mean_2014', 'mean_2015', 'mean_2016')
#test <- df_nl[, df_nl %in% cols == 0][df_nl ]
bins <- c(-0.1, -0.05, 0, 0.1, 0.2, 0.5, 1.5,10, 52)
pal <- colorBin("PuOr", domain = df_nl$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g DN",
df_nl$REGIONNAME, df_nl$WOREDANAME, round(df_nl$changes, 2)
) %>% lapply(htmltools::HTML)
m <- leaflet(df_nl) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(df_nl$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_nl$changes, opacity = 0.7, title = "Nightlight changes (DN) between 2000 and 2017", position = "bottomright")
palette <- brewer.pal(n = 9, name = "Blues")
p_urban <- spplot(df_nl, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightligt changes in ha")
p_urban

#plot_ly(p_urban)
Regional nightligt changes - Afar
afar <- df_nl[df_nl$REGIONNAME=="Afar", ]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = afar$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g digital value",
afar$REGIONNAME, afar$WOREDANAME, round(afar$changes, 3)
) %>% lapply(htmltools::HTML)
m <- leaflet(afar) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(afar$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 = afar$changes, opacity = 0.7, title = "Nightlight changes 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(afar, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends in 2000 and 2017 of Afar region")

#write.csv(afar, "afar_built-up.csv")
Regional nightligt changes - Amhara
Amhara <- df_nl[df_nl$REGIONNAME=="Amhara", ]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Amhara$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g digital value",
Amhara$REGIONNAME, Amhara$WOREDANAME, round(Amhara$changes, 3)
) %>% lapply(htmltools::HTML)
m <- leaflet(Amhara) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Amhara$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 = Amhara$changes, opacity = 0.7, title = "Nightlight changes between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Amhara, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Afar Amhara")

#write.csv(afar, "afar_built-up.csv")
Regional nightlight trends - Beneshangul Gumu
Beneshangul <- df_nl[df_nl$REGIONNAME=="Beneshangul Gumu",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Beneshangul$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g digital value",
Beneshangul$REGIONNAME, Beneshangul$WOREDANAME, Beneshangul$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Beneshangul) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Beneshangul$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 = Beneshangul$changes, opacity = 0.7, title = "Nightlight change changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Beneshangul, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of of Beneshangul Gumu region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - Dire Dawa
Dire_Dawa <- df_nl[df_nl$REGIONNAME=="Dire Dawa",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Dire_Dawa$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
Dire_Dawa$REGIONNAME, Dire_Dawa$WOREDANAME, Dire_Dawa$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Dire_Dawa) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Dire_Dawa$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 = Dire_Dawa$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Dire_Dawa, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Dire Dawa region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - Gambela
Gambela <- df_nl[df_nl$REGIONNAME=="Gambela",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Gambela$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
Gambela$REGIONNAME, Gambela$WOREDANAME, Gambela$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Gambela) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Gambela$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 = Gambela$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Gambela, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Gambela region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - Oromia
Oromia <- df_nl[df_nl$REGIONNAME=="Oromia",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Oromia$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
Oromia$REGIONNAME, Oromia$WOREDANAME, Oromia$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Oromia) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Gambela$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 = Oromia$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Oromia, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Oromia region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - SNNPR
SNNPR <- df_nl[df_nl$REGIONNAME=="SNNPR",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = SNNPR$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
SNNPR$REGIONNAME, SNNPR$WOREDANAME, SNNPR$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(SNNPR) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(SNNPR$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 = SNNPR$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(SNNPR, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of SNNPR region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - Somali
Somali <- df_nl[df_nl$REGIONNAME=="Somali",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Somali$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
Somali$REGIONNAME, Somali$WOREDANAME, Somali$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Somali) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Somali$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 = Somali$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Somali, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Somali region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")
Regional built-up changes - Tigray
Tigray <- df_nl[df_nl$REGIONNAME=="Tigray",]
bins <- c(-0.1, 0, 0.2, 0.5, 0.8, 1.5, 8, 10, 52)
pal <- colorBin("RdPu", domain = Tigray$changes, bins = bins)
labels <- sprintf("%s , <strong>%s</strong><br/>%g percent of woreda",
Tigray$REGIONNAME, Tigray$WOREDANAME, Tigray$changes
) %>% lapply(htmltools::HTML)
m <- leaflet(Tigray) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng=39.296289, lat =9.150055, zoom = 6)
m %>%
addPolygons(fillColor = ~pal(Tigray$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 = Tigray$changes, opacity = 0.7, title = "Build-up changes in % of woreda between 2000 and 2017", position = "bottomright") %>% addMiniMap()
# Plot
palette <- brewer.pal(n = 9, name = "RdPu")
spplot(Tigray, c('mean_2000', 'mean_2017'), names.attr = c("2000", "2017"),
col.regions = palette, cuts = length(palette) - 1, as.table=TRUE,
main = "Nightlight trends of Tigray region")

#write.csv(Beneshangul, "Beneshangul_built-up.csv")