Improving Performance of a leaflet
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to plot a map using Leaflet on Flexdashboard, output : html. I have a 50,000 data points i needed to plot. i tried using addCircleMarker(lng,lat)
and it works in Base R but when the output is generated in an HTML file the performance of the map is so slow. I also tried using leafletOptions(preferCanvas = TRUE)
but the performance is still very slow.
I also tried using a different library(leaflet.glify)
to improve performance as leaflet.glify
can handle large dataset and used addGlifyPoints(data, color = cbind(0, 0, 0.1), group = "All cases")
to plot the map. but i could not run it in an HTML output. It provided me with below error.
pandoc: Could not determine mime type for `/Library/Frameworks/R.framework/Versions/3.5/Resources/library/leaflet.glify/htmlwidgets/Leaflet.glify/src/shader/fragment/dot.glsl'
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/SelfContained.hs:156:35 in pandoc-1.19.2.1-JIeRA5EnQv74mk86CvVbbp:Text.Pandoc.SelfContained
Error: pandoc document conversion failed with error 1
Execution halted
Any help please.
r leaflet r-markdown flexdashboard leaflet.markercluster
add a comment |
I am trying to plot a map using Leaflet on Flexdashboard, output : html. I have a 50,000 data points i needed to plot. i tried using addCircleMarker(lng,lat)
and it works in Base R but when the output is generated in an HTML file the performance of the map is so slow. I also tried using leafletOptions(preferCanvas = TRUE)
but the performance is still very slow.
I also tried using a different library(leaflet.glify)
to improve performance as leaflet.glify
can handle large dataset and used addGlifyPoints(data, color = cbind(0, 0, 0.1), group = "All cases")
to plot the map. but i could not run it in an HTML output. It provided me with below error.
pandoc: Could not determine mime type for `/Library/Frameworks/R.framework/Versions/3.5/Resources/library/leaflet.glify/htmlwidgets/Leaflet.glify/src/shader/fragment/dot.glsl'
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/SelfContained.hs:156:35 in pandoc-1.19.2.1-JIeRA5EnQv74mk86CvVbbp:Text.Pandoc.SelfContained
Error: pandoc document conversion failed with error 1
Execution halted
Any help please.
r leaflet r-markdown flexdashboard leaflet.markercluster
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
Below is the library and its version[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
and my Rmarkdown version isrmarkdown_1.10
@SymbolixAU
– Prabesh Kc
Jan 3 at 9:43
add a comment |
I am trying to plot a map using Leaflet on Flexdashboard, output : html. I have a 50,000 data points i needed to plot. i tried using addCircleMarker(lng,lat)
and it works in Base R but when the output is generated in an HTML file the performance of the map is so slow. I also tried using leafletOptions(preferCanvas = TRUE)
but the performance is still very slow.
I also tried using a different library(leaflet.glify)
to improve performance as leaflet.glify
can handle large dataset and used addGlifyPoints(data, color = cbind(0, 0, 0.1), group = "All cases")
to plot the map. but i could not run it in an HTML output. It provided me with below error.
pandoc: Could not determine mime type for `/Library/Frameworks/R.framework/Versions/3.5/Resources/library/leaflet.glify/htmlwidgets/Leaflet.glify/src/shader/fragment/dot.glsl'
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/SelfContained.hs:156:35 in pandoc-1.19.2.1-JIeRA5EnQv74mk86CvVbbp:Text.Pandoc.SelfContained
Error: pandoc document conversion failed with error 1
Execution halted
Any help please.
r leaflet r-markdown flexdashboard leaflet.markercluster
I am trying to plot a map using Leaflet on Flexdashboard, output : html. I have a 50,000 data points i needed to plot. i tried using addCircleMarker(lng,lat)
and it works in Base R but when the output is generated in an HTML file the performance of the map is so slow. I also tried using leafletOptions(preferCanvas = TRUE)
but the performance is still very slow.
I also tried using a different library(leaflet.glify)
to improve performance as leaflet.glify
can handle large dataset and used addGlifyPoints(data, color = cbind(0, 0, 0.1), group = "All cases")
to plot the map. but i could not run it in an HTML output. It provided me with below error.
pandoc: Could not determine mime type for `/Library/Frameworks/R.framework/Versions/3.5/Resources/library/leaflet.glify/htmlwidgets/Leaflet.glify/src/shader/fragment/dot.glsl'
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/SelfContained.hs:156:35 in pandoc-1.19.2.1-JIeRA5EnQv74mk86CvVbbp:Text.Pandoc.SelfContained
Error: pandoc document conversion failed with error 1
Execution halted
Any help please.
r leaflet r-markdown flexdashboard leaflet.markercluster
r leaflet r-markdown flexdashboard leaflet.markercluster
asked Jan 3 at 3:37
Prabesh KcPrabesh Kc
124
124
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
Below is the library and its version[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
and my Rmarkdown version isrmarkdown_1.10
@SymbolixAU
– Prabesh Kc
Jan 3 at 9:43
add a comment |
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
Below is the library and its version[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
and my Rmarkdown version isrmarkdown_1.10
@SymbolixAU
– Prabesh Kc
Jan 3 at 9:43
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.
get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.
get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
Below is the library and its version
[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
Below is the library and its version
[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
and my Rmarkdown version is
rmarkdown_1.10
@SymbolixAU– Prabesh Kc
Jan 3 at 9:43
and my Rmarkdown version is
rmarkdown_1.10
@SymbolixAU– Prabesh Kc
Jan 3 at 9:43
add a comment |
1 Answer
1
active
oldest
votes
For leaflet.glify
you need to set self_contained: false
in your yaml header:
---
title: "testing gl"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
self_contained: false
---
### Chart 1
```{r}
library(mapview)
library(leaflet)
library(leaflet.glify)
library(sf)
n = 1e5
df1 = data.frame(id = 1:n,
x = rnorm(n, 10, 3),
y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)
options(viewer = NULL) # view in browser
system.time({
m = leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlifyPoints(data = pts, group = "pts") %>%
addMouseCoordinates() %>%
setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
addLayersControl(overlayGroups = "pts")
})
m
```
### Chart 2
```{r}
plot(cars)
```
Hi @TimSalabim i tried usingself_contained : false
and it renders theaddGlifyPoints
. and works perfectly when I open the HTML output within theR.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?
– Prabesh Kc
Jan 10 at 3:58
If your map is calledmap.html
there should also be a folder calledmap_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed
– TimSalabim
Jan 10 at 8:37
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016024%2fimproving-performance-of-a-leaflet%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For leaflet.glify
you need to set self_contained: false
in your yaml header:
---
title: "testing gl"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
self_contained: false
---
### Chart 1
```{r}
library(mapview)
library(leaflet)
library(leaflet.glify)
library(sf)
n = 1e5
df1 = data.frame(id = 1:n,
x = rnorm(n, 10, 3),
y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)
options(viewer = NULL) # view in browser
system.time({
m = leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlifyPoints(data = pts, group = "pts") %>%
addMouseCoordinates() %>%
setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
addLayersControl(overlayGroups = "pts")
})
m
```
### Chart 2
```{r}
plot(cars)
```
Hi @TimSalabim i tried usingself_contained : false
and it renders theaddGlifyPoints
. and works perfectly when I open the HTML output within theR.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?
– Prabesh Kc
Jan 10 at 3:58
If your map is calledmap.html
there should also be a folder calledmap_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed
– TimSalabim
Jan 10 at 8:37
add a comment |
For leaflet.glify
you need to set self_contained: false
in your yaml header:
---
title: "testing gl"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
self_contained: false
---
### Chart 1
```{r}
library(mapview)
library(leaflet)
library(leaflet.glify)
library(sf)
n = 1e5
df1 = data.frame(id = 1:n,
x = rnorm(n, 10, 3),
y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)
options(viewer = NULL) # view in browser
system.time({
m = leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlifyPoints(data = pts, group = "pts") %>%
addMouseCoordinates() %>%
setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
addLayersControl(overlayGroups = "pts")
})
m
```
### Chart 2
```{r}
plot(cars)
```
Hi @TimSalabim i tried usingself_contained : false
and it renders theaddGlifyPoints
. and works perfectly when I open the HTML output within theR.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?
– Prabesh Kc
Jan 10 at 3:58
If your map is calledmap.html
there should also be a folder calledmap_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed
– TimSalabim
Jan 10 at 8:37
add a comment |
For leaflet.glify
you need to set self_contained: false
in your yaml header:
---
title: "testing gl"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
self_contained: false
---
### Chart 1
```{r}
library(mapview)
library(leaflet)
library(leaflet.glify)
library(sf)
n = 1e5
df1 = data.frame(id = 1:n,
x = rnorm(n, 10, 3),
y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)
options(viewer = NULL) # view in browser
system.time({
m = leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlifyPoints(data = pts, group = "pts") %>%
addMouseCoordinates() %>%
setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
addLayersControl(overlayGroups = "pts")
})
m
```
### Chart 2
```{r}
plot(cars)
```
For leaflet.glify
you need to set self_contained: false
in your yaml header:
---
title: "testing gl"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
self_contained: false
---
### Chart 1
```{r}
library(mapview)
library(leaflet)
library(leaflet.glify)
library(sf)
n = 1e5
df1 = data.frame(id = 1:n,
x = rnorm(n, 10, 3),
y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)
options(viewer = NULL) # view in browser
system.time({
m = leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlifyPoints(data = pts, group = "pts") %>%
addMouseCoordinates() %>%
setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
addLayersControl(overlayGroups = "pts")
})
m
```
### Chart 2
```{r}
plot(cars)
```
answered Jan 8 at 15:51
TimSalabimTimSalabim
3,22911228
3,22911228
Hi @TimSalabim i tried usingself_contained : false
and it renders theaddGlifyPoints
. and works perfectly when I open the HTML output within theR.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?
– Prabesh Kc
Jan 10 at 3:58
If your map is calledmap.html
there should also be a folder calledmap_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed
– TimSalabim
Jan 10 at 8:37
add a comment |
Hi @TimSalabim i tried usingself_contained : false
and it renders theaddGlifyPoints
. and works perfectly when I open the HTML output within theR.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?
– Prabesh Kc
Jan 10 at 3:58
If your map is calledmap.html
there should also be a folder calledmap_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed
– TimSalabim
Jan 10 at 8:37
Hi @TimSalabim i tried using
self_contained : false
and it renders the addGlifyPoints
. and works perfectly when I open the HTML output within the R.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?– Prabesh Kc
Jan 10 at 3:58
Hi @TimSalabim i tried using
self_contained : false
and it renders the addGlifyPoints
. and works perfectly when I open the HTML output within the R.project
working directory, but the images are no longer displayed when I send the file to someone. Not sure what is going on there? does anyone have this issue ?– Prabesh Kc
Jan 10 at 3:58
If your map is called
map.html
there should also be a folder called map_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed– TimSalabim
Jan 10 at 8:37
If your map is called
map.html
there should also be a folder called map_files
where all necessary code is stored (that's what selfcontained false means). You will need to send both the html and the folder to get the map displayed– TimSalabim
Jan 10 at 8:37
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016024%2fimproving-performance-of-a-leaflet%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what version of pandoc do you have installed? I've found v2.1 solved this type of error.
– SymbolixAU
Jan 3 at 3:40
im using 2.1 but nothing changed for me. Still have issue with performance when plotting 50,000 data points.
get_pandoc_version()`` [1] 2.1
– Prabesh Kc
Jan 3 at 9:22
Below is the library and its version
[1] googleway_2.7.1 bindrcpp_0.2.2 sf_0.7-2 readxl_1.1.0 [5] colourvalues_0.2.1 leaflet.glify_0.1.1 forcats_0.3.0 stringr_1.3.1 [9] purrr_0.2.5 readr_1.1.1 tidyr_0.8.2 tibble_1.4.2 [13] ggplot2_3.1.0 tidyverse_1.2.1 dplyr_0.7.7 htmltools_0.3.6 [17] htmlwidgets_1.3 rgeos_0.4-2 rgdal_1.3-6 sp_1.3-1 [21] leaflet_2.0.2 flexdashboard_0.5.1.1 pandocfilters_0.1-1
– Prabesh Kc
Jan 3 at 9:40
and my Rmarkdown version is
rmarkdown_1.10
@SymbolixAU– Prabesh Kc
Jan 3 at 9:43