Why to visualise water supply of Spain per regions?

Spain is one of the most water stressed countries of Europe, this means that the ratio of water withdrawals to supply is one of the highest. This is potentially one of the main challenges Spain will have to face in the 21st century.

One of the very first analysis that could be done before addressing this issue is to see how unequal the water supply is distributed within Spain.

Therefore, the following map shows the water supply per squared kilometer for each main region in Spain in 2016 (last year of available data):

library(leaflet)

# Map data from ref.1 GADM database 
spain<-readRDS("gadm36_ESP_1_sp.rds")

# Water supply data from ref.2 and ref.3 post-processed to match the rds file.
WATER2016<-read.csv("WATER2016.csv")

# Integrating Water dataset within the RDS file
spain@data$WA2016<-WATER2016$W.A
# Set up color palette with the higher and smaller value of the WA2016 dataset, and reverse color scheme to show the red for lower values. 
pal <- colorNumeric(
  palette = "Reds",
  domain = spain@data$WA2016, reverse = TRUE)

# Content of the label when hovering a region
labels <- sprintf(
  "<strong>%s</strong><br/>%g m<sup>3</sup>/km<sup>2</sup>",
  spain@data$NAME_1 , spain@data$WA2016
) %>% lapply(htmltools::HTML)

# Create leaflet object

map<- leaflet(spain) %>%
      addTiles() %>%
       setView( lat=40, lng=-5 , zoom=6) %>%
    addPolygons( weight = 2,
                 opacity = 1,
                 color = "white",
                 dashArray = "3",
                 fillOpacity = 0.7,
                fillColor = ~pal(WA2016),
                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("bottomright", pal = pal, values = ~WA2016,
            title = "Water Supply (2016)",
            labFormat = labelFormat(suffix = " m³/km²"),
            opacity = 1
  )

map

Data from:

ref.1 GADM database

ref.2 Water supply - official country database

ref.3 Surface of Spanish regions