This has to be an easy fix but this is my first time using mapview and mapshot and I'm stuck. I've investigated other postings and the documentation but I can't see a source.
I've created an object with mapview. I can view the map ok and I can export and save successfully from the viewer. However, I'm trying to save from code using mapshot.
This works great with an html output but not for the png. No error messages show and the file saves in the right place absolutely fine. It's just that the saved PNG file shows a map and no data.
library(openair)
library(dplyr)
library(mapview)
sites <- importMeta(source = "saqn", all = FALSE)
edinburgh_sites <- sites %>% filter(substr(site, 1, 9) == "Edinburgh")
glimpse(edinburgh_sites)
Rows: 14 Columns: 5 $ site "Edinburgh Centre", "Edinburgh Currie", "Edinbur… $ code "ED", "ED11", "ED10", "ED5", "ED6", "ED2", "EDNS… $ latitude 55.95197, 55.89691, 55.93903, 55.93771, 55.94583… $ longitude -3.195775, -3.319660, -3.392727, -3.232267, -3.2… $ site_type "Urban Background", "Suburban Background", "Urba…
edinburgh_sites_map = mapview(edinburgh_sites, xcol = "longitude", ycol = "latitude", crs = 4326, grid = FALSE)
edinburgh_sites_map
mapshot(edinburgh_sites_map,
file = paste0(getwd(), "/Figures/edin_sites_map.png"))