Skip to content

Commit

Permalink
update data
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarty committed May 25, 2024
1 parent 51c595a commit aa7e873
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 107 deletions.
2 changes: 1 addition & 1 deletion notebooks/nighttime-lights/02_extract_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ for(unit in c("adm0", "adm1", "adm2", "adm3", "city")){

# Append files -----------------------------------------------------------------
for(unit in c("adm0", "adm1", "adm2", "adm3", "city")){
for(time_period in c("annually", "monthly", "daily")){ # "daily"
for(time_period in c("annually", "monthly")){ # "daily"

ntl_df <- file.path(ntl_dir, "aggregated_individual", unit, time_period) %>%
list.files(full.names = T) %>%
Expand Down
209 changes: 105 additions & 104 deletions notebooks/nighttime-lights/ntl_analysis.html

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions notebooks/nighttime-lights/ntl_analysis.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,13 @@ adm3_df_line <- adm3_df %>%
}, .id = 'ADM3_PCODE')
## Merge data with sf object
adm3_df <- adm3_df[!is.na(adm3_df$ADM3_PCODE),]
adm3_sf <- adm3_sf %>%
right_join(adm3_df, by = c("ADM3_PCODE")) %>%
left_join(adm3_df_line, by = "ADM3_PCODE")
adm3_sf <- adm3_sf %>%
mutate(popup = paste0("<h4>", ADM3_FR, "</h4>",
dplyr::mutate(popup = paste0("<h4>", ADM3_FR, "</h4>",
"<b>NTL ", substring(date, 1, 7), ":</b> ", round(ntl_sum, 2), "<br>",
"<b>NTL Baseline:</b> ", round(ntl_sum_baseline, 2), "<br>",
"<b>Trends in NTL since Jan 2023</b><br><br>",
Expand All @@ -471,7 +472,7 @@ add_deps <- function(dtbl, name, pkg = name) {
leaflet() %>%
addProviderTiles(providers$OpenStreetMap.HOT) %>%
addPolygons(data = adm3_sf[adm3_sf$date == ymd("2023-07-01"),],
addPolygons(data = adm3_sf[adm3_sf$date %in% ymd("2023-07-01"),],
fillColor = ~pal(ntl_pc),
color = line_color, opacity = opacity, fillOpacity = fill_opacity,
label = ~lapply(popup, HTML),
Expand Down

0 comments on commit aa7e873

Please sign in to comment.