Open mrworthington opened 2 years ago
I cannot reproduce the File Size problem.
When I use the following example, the rdeck
map is bigger (3.7MB) and leafgl
is around 1.8MB.
Concerning the "blurriness".. I guess this is because Leaflet.glify rescales the points depending on the zoom level and rdeck has a "static" size it seems. And maybe these open PR's could also improve this: https://github.com/robertleeplummerjr/Leaflet.glify/pull/138 https://github.com/robertleeplummerjr/Leaflet.glify/pull/127
library(leaflet)
library(leafgl)
library(sf)
library(rdeck)
library(dplyr)
library(sf)
library(viridis)
library(RcppSimdJson)
url <- file.path(
"https://raw.githubusercontent.com/visgl/deck.gl-data/master",
"examples/scatterplot/manhattan.json",
fsep = "/"
)
manhattan_data <- fload(url) %>%
as_tibble(.name_repair = ~ c("lon", "lat", "species")) %>%
mutate(
position = sfc_point(lon, lat),
species = as.factor(species),
species_name = if_else(species == 1, "dog", "cat")
)
rdeckmap <- rdeck(
map_style = mapbox_dark(), initial_bounds = st_bbox(manhattan_data$position)) %>%
add_scatterplot_layer(radius_scale = 30,
data = manhattan_data, get_position = position,
get_fill_color = scale_color_category(
col = species, palette = cividis(2)))
pts = st_as_sf(manhattan_data, coords = c("lat", "lon"), crs = 4326)
leafglmap <- leaflet() %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
addGlPoints(data = pts,
group = "pts", fillColor = "species")
htmlwidgets::saveWidget(widgetframe::frameableWidget(rdeckmap),
file = "rdeckmap_map.html",
selfcontained = TRUE,
background = "white")
htmlwidgets::saveWidget(widgetframe::frameableWidget(leafglmap),
file = "leafglmap_map.html",
selfcontained = TRUE,
background = "white")
Hi y'all,
Currently reworking a map I made that's going to have at least ~50k points in total, with the potential for more layers. Right now, I'm trying to evaluate {rdeck} and {leafgl} and I'm currently leaning toward {leafgl} because y'all have a lot of native integration with leaflet, which enables the map to have more functionality, but I've got two issues I'm thinking through that stand out to me (Also, I'm happy to file these as two separate issues:
For reference, here's links to each map:
Links to Maps
Point Pixelation and Resolution
As I've been testing out {leafgl} and {rdeck}, I've noticed a blurriness and pixelation with the points rendered by leafgl. I'm wondering what options there are to increase the resolution of the points? Here's a screenshot:
{leafgl} screenshot
{rdeck} screenshot
Code for leafgl point rendering
Right now, this is how I'm drawing the points with leafgl:
File Size for Standalone Maps
The last thing I'm wondering about is the difference between file sizes produced for a standalone HTML version when using {leafgl} vs {rdeck}. Using the same data for each map, I used
htmlwidgets::saveWidget()
to create self-contained versions of the maps, like this:When I did, the {leafgl} map was roughly 56.8 MB while the {rdeck} map was 4.4 MB. Is there a way to reduce the file size of the leafgl map?
Session Info