[R-sig-Geo] Leaflet map nested in RShiny App - Improving speed & portability
Erin Stearns
e@te@rn@88 @ending from gm@il@com
Thu Sep 6 19:40:59 CEST 2018
Thank you, Mike! Yes, I have used htmlwidgets, thank you for that! The
issue is the file begins unwieldy given the amount of data contained in my
leaflet app.
Yeah, it seems like there are a number of options, it's just trying to
determine the best is the tricky part.
Thanks again for the ideas - very much appreciated.
Best,
Erin
On Wed, Sep 5, 2018 at 11:02 AM Michael Treglia <mtreglia using gmail.com> wrote:
> I'll just second Barry's idea in particular, to set up as a standalone
> webpage. You could even use QGIS and the QGIS2Web Plugin to create that,
> and host via GitHub pages or similar.
>
> From R, after creating a map via leaflet and similar packages, you can use
> htmlwidgets::saveWidget() to export as a standalone .html file if I recall
> correctly.
>
> The one thing regarding a standalone webpage is that if you have a lot of
> objects (especially complex ones), that can be a lot for a browser to
> handle (given the data are part of the html file). Might be worth some
> quick experimentation, and simplifying polygons would help. (You could
> always create a quick landing page, even generated via rMarkdown, and
> having a link for maps by different regions or countries - then you could
> have a folder of .html files you could distribute, and users could just
> open the landing page, and navigate from there).
>
> Just some quick thoughts... Hope this helps.
> Mike T
>
> On Wed, Sep 5, 2018 at 1:17 PM Erin Stearns <estearns88 using gmail.com> wrote:
>
>> Hello all,
>>
>> Thank you all very much for the great insight!
>>
>> *McCrea *- thank you very much, I will test using a geojson first, then
>> test after reducing geometry.
>>
>> *Tim* - thank you for the great breakdown and recommended priority list.
>> Ideally, I would like to be able to share the interactive map with
>> teammates as a file or something akin to it such that they can simply open
>> it and interact with the map. RInno is a great option, however I run a
>> linux machine, so will look into further, but may need to find another
>> option.
>>
>> *Roman* - the app is currently deployed to shinyapps.io. Thank you for
>> sharing about ShinyProxy -- so would this method require 1. Internet and
>> 2.
>> local installation (vs internal server)?
>>
>> *Barry* - wow, thank you for your response! Sounds like this would be the
>> best way to solve both issues. I am not as fluent with HTML and JS, but as
>> you say, there are likely great guides available to take this route.
>>
>> Thank you all again, this has been hugely helpful. I wish you all the best
>> and hope I can be of help to you at some point!
>>
>> Best,
>> Erin
>>
>>
>> On Wed, Sep 5, 2018 at 12:48 AM Barry Rowlingson <
>> b.rowlingson using lancaster.ac.uk> wrote:
>>
>> >
>> >
>> > On Wed, Sep 5, 2018 at 12:56 AM, Erin Stearns <estearns88 using gmail.com>
>> > wrote:
>> >
>> >> Hello all!
>> >>
>> >> I hope this message finds you all well!
>> >>
>> >> I have 2 questions pertaining to the creation of interactive maps via
>> >> Leaflet nested inside an RShiny app. One question has to do with
>> >> computation while the other has to do with sharing/off-line
>> interactivity.
>> >>
>> >> *Computation question*
>> >> As you see, the RShiny app takes quite a bit of time to render. Does
>> >> anyone
>> >> have any suggestions for improving this? As previously said, this
>> version
>> >> only contains 5 countries, thus I cannot continue with my current
>> method
>> >> to
>> >> reach a global map. I have considered finding centroids of all Admin 2
>> >> polygons and retaining attribute information here, then rasterizing the
>> >> malaria risk shapefile for visualization and using the 2 instead of a
>> >> single shapefile with polygon boundaries and attributes.
>> >>
>> >>
>> > Unless you plan to add any computational functions to this map then I'd
>> > strongly recommend creating it as a standalone web app and not a shiny
>> app.
>> > This will enable you to use lots of useful Leaflet plugins for speeding
>> > things up, such as only showing country outlines at low zoom levels, and
>> > showing subdivisions only at high zoom levels. This *might* be possible
>> > with R's various leaflet packages but I'd go for full javascript
>> control.
>> >
>> > A standalone map would take its data from a JSON file or similar, and
>> you
>> > would then be writing R code that generated that. The mapping app
>> itself is
>> > written in HTML and JS with CSS styling. There are plenty of guides to
>> > web-based interactive mapping, starting with Leaflet.
>> >
>> >
>> >> *Sharing the app/offline interactivity*
>> >> I am planning to share this with people who likely do not have R
>> installed
>> >> on their laptops nor have they ever coded. Does anyone have any
>> >> suggestions
>> >> for the best way to do this while retaining interactivity?
>> >>
>> >> Here's the big win of creating a standalone web map. You only have to
>> > distribute the HTML/CSS/JS and they can be viewed directly (or you also
>> > supply a tiny server that runs locally and only has to feed the files
>> on a
>> > localhost port). No need to have a shiny server anywhere, or install R.
>> Its
>> > simple and clean. It also needs no network connectivity, but you'll not
>> get
>> > a base map - but you could include a low or medium resolution basemap
>> > raster in your package.
>> >
>> > The only reason to need Shiny here would be if you wanted people to do
>> > something computational, like click on a bunch of polygons and then fit
>> a
>> > linear model to the selection, since that would require a round-trip to
>> the
>> > server for R to compute the fit. (although I suspect there's a JS
>> package
>> > for linear modelling.... you can do ML in JS these days...)
>> >
>> >
>> >
>> >> Thank you all, any insight is greatly appreciated.
>> >>
>> >> Best,
>> >> Erin
>> >>
>> >> [[alternative HTML version deleted]]
>> >>
>> >> _______________________________________________
>> >> R-sig-Geo mailing list
>> >> R-sig-Geo using r-project.org
>> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >>
>> >
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list