2

I've found this code about a map with road traffic casualties across the UK done with mapdeck.

I would like to create something similar for Italy, but I don't understand how to modify the code to obtain italian area.

library(mapdeck)
set_token(Sys.getenv("MAPBOX"))
crash_data = read.csv("https://git.io/geocompr-mapdeck")
crash_data = na.omit(crash_data)
ms = mapdeck_style("dark")
mapdeck(style = ms, pitch = 45, location = c(0, 52), zoom = 4) %>%
add_grid(data = crash_data, lat = "lat", lon = "lng", cell_size = 1000,
         elevation_scale = 50, layer_id = "grid_layer",
         colour_range = viridisLite::plasma(6))

Thank you!

ArTu
  • 431
  • 4
  • 20

1 Answers1

2

I think the data which you have given is for Italy. If it is the case then it is perfectly fine. This is the solution for your problem. Just change the locations latitude and longitude value.

library(mapdeck)

set_token(Sys.getenv("MAPBOX"))

crash_data = read.csv("https://git.io/geocompr-mapdeck")

crash_data = na.omit(crash_data)
ms = mapdeck_style("dark")
mapdeck(style = ms, pitch = 45, location = c(43,12), zoom = 4) %>%
  add_grid(data = crash_data, lat = "lat", lon = "lng", cell_size = 1000,
           elevation_scale = 50, layer_id = "grid_layer",
           colour_range = viridisLite::plasma(6))

If this has answered your question it is well and good. You can also edit the other fine details.

Luiy_coder
  • 321
  • 2
  • 11