source(here::here("_rinit.R"))
source(here::here("data", "paris", "_paris.R")) # wkb2sfc(), paris_basemap(), arrondissements_sf()
invisible(Sys.setlocale("LC_TIME", "fr_FR.UTF-8"))
# cd ~/iCloud/website/data/paris; /usr/local/bin/R -e 'quarto::quarto_render("arbresremarquablesparis.qmd")'
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE,
fig.width = 8, fig.height = 5, dpi = 150)
rem_path <- here::here("data", "paris", "arbresremarquablesparis.parquet")
rem <- arrow::read_parquet(rem_path) |>
dplyr::mutate(
qualification = com_qualification_rem,
annee = as.integer(format(arbres_dateplantation, "%Y")),
ar = suppressWarnings(as.integer(gsub("er$", "", com_arrondissement))),
stade = dplyr::recode(arbres_stadedeveloppement,
"J" = "Jeune", "A" = "Adulte", "M" = "Mature",
.missing = "Non renseigné")
)
n_tot <- nrow(rem)
arr_sf <- arrondissements_sf()
pts_sf <- rem |>
dplyr::mutate(geometry = wkb2sfc(geom_x_y)) |>
sf::st_as_sf(crs = 4326)
theme_carte <- theme_void(base_size = 12) +
theme(plot.title = element_text(face = "bold"),
plot.subtitle = element_text(colour = "grey35"),
plot.margin = margin(5, 12, 5, 5))
theme_barres <- theme_minimal(base_size = 12) +
theme(plot.title = element_text(face = "bold"),
plot.subtitle = element_text(colour = "grey35"),
panel.grid.major.y = element_blank())
pal_qual <- c(Paysager = "#2f6f4f", Botanique = "#7a5a2b",
Symbolique = "#8a4fae", Historique = "#c0392b")
tree_card <- function(row) {
# Single line, no embedded newlines/indentation: this gets cat()-ed into a
# results="asis" chunk, and pandoc treats 4+ leading spaces on a line as
# an indented markdown code block -- which silently HTML-escapes the tags.
paste0(
'<div style="display:flex;gap:.9rem;margin-bottom:1.2rem;align-items:flex-start">',
'<img src="', row$com_url_photo1, '" alt="" loading="lazy" ',
'style="width:150px;height:150px;object-fit:cover;border-radius:.4rem;flex:0 0 auto">',
'<div><b>', row$com_nom_usuel, '</b> — ', row$com_site, '<br>',
'<span style="color:#888;font-size:.85rem">planté vers ',
ifelse(is.na(row$annee), "date inconnue", row$annee), '</span><br>',
row$com_descriptif, ' ',
'<a href="', row$com_url_pdf, '" target="_blank">fiche PDF ↗</a>',
'</div></div>'
)
}