Pesticides
[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Day 24 of 30DayMapChallenge: « Only circular shapes » (previously).
We’ll map the pesticides bought in France as a Dorling cartogram (Dorling 1996).
Config
library(readr) library(dplyr) library(tidyr) library(stringr) library(ggplot2) library(glue) library(janitor) library(sf) library(fs) library(cartogram) library(ggrepel)
Data
Get the data from the Declarations of sales of plant protection products.
Select:
- Achats
- 2022
- Code postal de l’acheteur
- Substance
- France entière
and wait to get the download link by mail.
# get french départements from # https://static.data.gouv.fr/resources/admin-express-cog-simplifiee-2024-metropole-drom-saint-martin-saint-barthelemy/20240930-094021/adminexpress-cog-simpl-000-2024.gpkg dep <- read_sf("~/data/adminexpress/adminexpress-cog-simpl-000-2024.gpkg", layer = "departement") |> filter(insee_reg > "06") |> st_transform("EPSG:2154") unzip("BNVD_TRACABILITE_20241124_102856_ACHAT_.zip", exdir = "bnvd") bnvd <- dir_ls("bnvd", regexp = "ACHAT_CP_SUBSTANCE_(?!INDETERMINEE).*\\.csv$", perl = TRUE) |> read_delim(delim = ";", na = c("-", "nc", ""), col_types = cols(code_sandre_substance = col_character())) |> filter(code_postal_acheteur < "97000") dir_delete("bnvd")
The {cartogram} package is used to generate the circles.
# Adding pesticides info to the polygons bnvd_dep <- dep |> left_join(bnvd |> group_by(code_departement_acheteur) |> summarise(substance_kg = sum(quantite_substance, na.rm = TRUE)), join_by(insee_dep == code_departement_acheteur)) |> mutate(w = 1 - (substance_kg / max(substance_kg))) bnvd_dorling_dep <- bnvd_dep |> cartogram_dorling(weight = "substance_kg", m_weight = bnvd_dep$w)
Map
bnvd_dorling_dep |> ggplot() + geom_sf(fill = "palevioletred2", color = "maroon4", linewidth = 1) + geom_text_repel(aes(label = insee_dep, geometry = geom), stat = "sf_coordinates", force = 0.001, size = 3, color = "red4", bg.r = 0.1, bg.color = "pink") + labs(title = "Pesticides bought in France", subtitle = "départements - 2022", caption = glue("https://r.iresmi.net/ - {Sys.Date()} data: Substance weight - BNV-D (OFB)")) + theme_void() + theme(plot.caption = element_text(size = 6, color = "darkgrey"), text = element_text(color = "#ddd"), panel.background = element_blank(), plot.background = element_rect(fill = "grey10", color = NA), plot.margin = unit(c(5, 5, 5, 5), "mm"))
In this figure, we map more than just the pesticides bought: the area and the agriculture type in the département are the main drivers of the circles size. Vineyards, orchards and field crops (cereals, beets,…) are the most intensive users of pesticides.
References
Dorling, Daniel. 1996. “Area Cartograms: Their Use and Creation.” Concepts and Techniques in Modern Geography, no. 59. https://ora.ox.ac.uk/objects/uuid:5e9483f5-3e1c-4038-b10f-d09c5767c285.
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.