Introduction to VEClim Tile Maps

This tutorial provides a concise, step-by-step guide to accessing and visualising VEClim risk maps in R using the leaflet package. It is intended as a quick introduction to working with VEClim’s tile-based map services.

The example below demonstrates how to generate an interactive map similar to the one shown:

VEClim Map Tiles

In [ ]:
library(leaflet)

leaflet() |>
  addProviderTiles(providers$CartoDB.Positron) |>
  addTiles(
    urlTemplate = "https://veclim.com/api?v=colegg&x={x}&y={y}&z={z}",
    attribution = "VEClim"
  ) |>
  setView(lng = 33.4, lat = 35.2, zoom = 3)

In addition to visualising the tiles directly, you can also query the VEClim API to retrieve metadata about the available map layers, including their identifiers and associated colour scales.

The following example shows how to request a list of available tile layers and inspect the colour key for a selected layer:

In [12]:
library(httr2)
library(jsonlite)

txt <- request("https://veclim.com/api?v=tiles") |> req_perform() |> resp_body_string()
js  <- fromJSON(txt, simplifyVector = FALSE)

js['colegg']
$colegg =
$colors
  1. '#00000000'
  2. '#fbe590'
  3. '#fcc65a'
  4. '#f7a034'
  5. '#f47b2c'
  6. '#e85229'
  7. '#d82929'
  8. '#931b1f'
$labels
  1. '1/16'
  2. '1/8'
  3. '1/4'
  4. '1/2'
  5. '1'
  6. '2'
  7. '4'
  8. '8'
  9. '16'