[R-sig-Geo] Leaflet map nested in RShiny App - Improving speed & portability

Tim Appelhans tim@@ppelh@n@ @ending from gm@il@com
Wed Sep 5 07:40:26 CEST 2018


Hi Erin,

a couple of thoughts regarding computation:

1. you could try using the preferCanvas option in leaflet(options = 
leafletOptions(preferCanvas = TRUE) which likely won't help to speed up 
the rendering but should make the map more responsive.

2. simplify your shapes using the rmapshaper package. Your shapes, 
especially coastlines are quite detailed which puts heavy load on the 
browser.

3. maybe use a simpler world file all-together with less details. I am 
especially thinking of small islands and such.

(My personal priority list would be 3, 2, 1)

Regarding sharing I am not sure I understand. Do you mean sharing as in 
hosting it somewhere on a server, or sharing a file (or similar) with 
someone? If the latter, the RInno package may help (though only supports 
windows).

HTH,

Tim


On 09/05/2018 01:56 AM, Erin Stearns 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.
>
> *Project description:*
> I am creating a global map depicting binary malaria risk (at risk, not at
> risk) at the Admin 2 level(current state only uses 5 countries and can be
> found here <https://erstearns.shinyapps.io/malariarisk5/>).  I am using an
> ESRI base map, then a polygons shapefile containing geometry and attributes
> (geographical hierarchy & risk).
>
> *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.
>
> *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?
>
> 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



More information about the R-sig-Geo mailing list