gpt4 book ai didi

Using Plotly Mapboxes Offline in R(在R中脱机使用打印地图框)

转载 作者:bug小助手 更新时间:2023-10-24 22:03:13 26 4
gpt4 key购买 nike



I'm working on an R shiny app, which uses ggplot to overlay a series of lines on a map of the world. Since the lines can overlap, I have a control panel which dynamically updates a checkbox input to make sure I have one checkbox item per map line, with which I can hide/reveal lines.

我正在开发一款R Shiny应用程序,它使用gglot在世界地图上叠加一系列线条。因为线条可以重叠,所以我有一个控制面板,它可以动态更新复选框输入,以确保每条地图线都有一个复选框项,我可以用它来隐藏/显示线。


I think it would be cleaner and more user friendly if I were to use plotly mapboxes. Not only does this look nicer and allow the user greater freedom to navigate the map, it also means I don't have an ever growing checkbox region taking up half the app window. With the example on the plotly website, I've been able to prove to myself that this looks and feels better.

我认为如果我使用情节地图框,它会更干净,用户更友好。这不仅看起来更好,让用户有更大的自由来导航地图,还意味着我没有一个不断扩大的复选框区域占据应用程序窗口的一半。通过这个网站上的例子,我已经向自己证明了这个看起来和感觉都更好。


The problem is, I need my app to also be able to work without an internet connection. For my old ggplot method, this is fine, as I was able to download some specific tilesets with ggmap::get_stamenmap(), convert those to an rds, and read them offline with readRDS from base.

问题是,我需要我的应用程序也能够在没有互联网连接的情况下工作。对于我以前的ggplot方法来说,这很好,因为我可以用ggmap::get_stamenmap()下载一些特定的平铺集,将它们转换为rds,然后用readRDS从base离线读取它们。


Is there a way that I could continue to use plotly's mapboxes offline? Would I be on the right track with the downloaded tilesets that I already have?

有没有办法让我可以离线继续使用Ploly的地图框?使用我已经拥有的已下载的磁贴集,我会走上正确的道路吗?




I've just added a post about this here on the plotly forums. I want to keep these posts linked in case somebody finds one in the future, and can get useful information from the other one.

我刚刚在PLATLY论坛上添加了一篇关于这方面的帖子。我想保持这些帖子的链接,以防将来有人发现一个帖子,并可以从另一个帖子获得有用的信息。


更多回答

This seemed interesting, so I did a brief search. I found a reddit thread that suggests one path would be to have a local tile server: community.plotly.com/t/plotly-v4-dash-offline-map/33876 and community.plotly.com/t/offline-scattergeo-plots-not-working/…. (Another option? github.com/burakbayramli/simplegeomap.) I've done none of that, sorry, just reposting for discussion.

这似乎很有趣,所以我做了一个简短的搜索。我找到了一个Reddit帖子,该帖子建议使用本地切片服务器:community.plotly.com/t/plotly-v4-dash-offline-map/33876和community.plotly.com/t/offline-scattergeo-plots-not-working/…。(另一种选择?Githorb.com/burakbayramli/implegeomap。)对不起,我什么都没做,只是转帖供讨论。

@r2evans Thanks for the suggestions! Unfortunately, I've also come across that reddit thread and the plotly community posts. Those seem geared more towards Dash (Python), and aren't necessarily 1:1 with R. However, the idea of hosting a local offline tile server is a possibility, but it's something I'm unfamiliar with and was hoping to keep on the back burner. Simplegeomap certainly has a good description, but it looks like it's also for Python. Maybe I can find an R version of it? But I was hoping to use Plotly to have the integrated line selections. Thanks!

@r2evans感谢您的建议!不幸的是,我也看到了Reddit的帖子和情节复杂的社区帖子。它们似乎更倾向于Dash(Python),并不一定与R一对一。然而,托管本地离线磁贴服务器的想法是有可能的,但这是我不熟悉的事情,我希望将其搁置一边。Simplegeomap当然有一个很好的描述,但它看起来也是针对Python的。也许我能找到它的R版本?但我希望使用Ploly来进行集成的线条选择。谢谢!

优秀答案推荐

So, I didn't derive the solution I was expecting, but I did come up with something functional.

所以,我没有得到我期望的解决方案,但我确实想出了一些实用的解决方案。


I was able to take the locally downloaded tileset, plot it with ggmap and geom_sf for my lines, and just feed that into a ggplotly and renderPlotly. This is similar enough to what I was hoping to achieve that I'm not going to continue pursuing mapboxes.

我可以使用本地下载的tillplot,用ggmap和geom_sf绘制我的行,然后将其输入ggplotly和renderPlotly。这与我希望实现的目标非常相似,我不打算继续追求地图盒。


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com