【问题标题】:r - mapview cant handle big sf dataframer - mapview 无法处理大的 sf 数据帧
【发布时间】:2018-08-30 05:11:52
【问题描述】:

我试图用 ma​​pview::mapview() 在 R 中可视化一个包含大约 1000 行的 linestrings 的大型 sf 数据框 。不幸的是,当我执行命令时出现警告:

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 stack exchange 上发布了这个问题,但我认为在这里发布也可能会有所帮助。

【问题讨论】:

  • 免责声明:此处为 mapview 开发人员。此行为(以及随附的警告)旨在变得更智能,并切换到通常更适合显示大型特征的模式,否则可能会导致地图的响应速度变慢。诚然,拥有一个适用于所有情况下所有几何类型的通用阈值(例如,一个具有许多顶点的大多边形与许多简单多边形)很难,而且可能并不总是有效。我们实施的阈值是根据经验选择的。当传单更新到 1.3.1 时,这种行为将在不久的将来发生变化。
  • 关于将地图保存为 html 的问题,请尝试设置 selfcontained = FALSE,这通常适用于较大的几何图形。
  • 你的回答总是很感激蒂姆。谢谢
  • 我一直很感激关于如何改进形状/几何复杂度计算的建议here

标签: r gis android-mapview sf


【解决方案1】:

帮助修复错误的事情:

  1. 添加 maxpoints 参数:

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

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

  1. 按照 TimSalabim 的建议设置 selfcontained = FALSE 以导出为 .html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 2011-07-28
    • 2015-05-16
    • 2018-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多