Cannot knit RMD with mapview

Hi there,

I am trying to knit an RMarkdown file to an HTML that contains code to use the mapview package. I keep getting an error and tons of research into the problem, I still can't figure it out.

Here is my code:

# Grand Rapids gage at 42.96308 and -85.67725
GRlat <- 42.96308
GRlong <- -85.67725
# Eastmanville gage at 43.02419 and -86.02644
EAlat <- 43.02419
EAlong <- -86.02644
# Let's plot them and see where they are relative to each other
library(sp)
gages <- c("Grand Rapids", "Eastmanville")
lat <- c(GRlat, EAlat)
long <- c(GRlong, EAlong)
coords <- data.frame(long, lat)
dat <- data.frame(gages)
pts <- SpatialPointsDataFrame(coords, dat)

library(sf)

stations <- st_as_sf(pts)
stations <- stations %>% st_set_crs(st_crs(4326))

library("mapview")
library("leaflet")
map <- mapview::mapview(stations)
map

The map works perfectly fine when I run the code. However, when I try to knit the document, here is the error message I get:

Could not determine mime type for `C:\Users\KKEETON\AppData\Local\Temp\RtmpCoAUnm\file44c86f4228d0\stations_layer.fgb'
Error: pandoc document conversion failed with error 63
Execution halted

I found a similar problem on StackOverflow where they used this code:

mapshot(map, "map.html", selfcontained=FALSE)

But I'm not sure what .html file is supposed to be there. I tried it with "map.html" and nothing happened.

Any help would be so greatly appreciated!

Thank you so much!

The fundamental issue is that mapview and leaflet are designed for interactive use and the mapview object created by the code is not readily knitted. There are other ways of displaying and and knitting to pdf a ggplot representation of an sf object, which should be explored.

I did have the same problem. View the end of https://github.com/HanOostdijk/HOQCwfs/blob/main/README.Rmd to see how I solved it.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.