r - mapview 无法处理大 sf 数据框

r - mapview cant handle big sf dataframe

我正在尝试可视化一个大型 sf 数据框,其中大约 1000 行包含 linestringsmapview[=25= R 中的 ]::mapview()。不幸的是,当我执行命令时出现警告:

mapview(data.frame)

Warning message:
In leaflet_sfc(sf::st_geometry(x), map = map, zcol = zcol, color = clrs,  :
  the supplied feature layer has more points/vertices than the set threshold.
  using special rendering function, hence things may not behave as expected from a standard leaflet map,
  e.g. you will likely need to zoom in to popup-query features

  to see the number of points/vertices of the layer use 'npts(x)'
  to see the threshold for the feature type use 'mapview:::getMaxFeatures(x)'
  to adjust the threshold use argument 'maxpoints'

然后我尝试导出为 html,我得到:

R代码执行错误

并且保存的文件是0 kb。如果包中有一些其他功能的修复或解决方法,我将不胜感激?

我也在 gis 堆栈交换上 post 编辑了这个问题,但我认为它也可能对 post 这里有帮助。

帮助修复错误的事情:

  1. 添加 maxpoints 参数:

    mapview::mapview(data.frame, maxpoints = 1000000)

这似乎增加了先前设置的绘制最大特征数的阈值。

  1. 设置 selfcontained = FALSE 以导出为 .html,如 TimSalabim
  2. 所提议