[R-sig-Geo] viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Tim Salabim t|m@@ppe|h@n@ @end|ng |rom gm@||@com
Wed Mar 11 11:34:08 CET 2020


Hi Nevil,
while not being able to help with mbtiles, maybe you want to try
leafgl to view your polygons.

https://github.com/r-spatial/leafgl

It should have no problems with 40k polygons.

Regarding RStudio's leaflet.mapboxgl, I don't think it is intended for
local use (though I might be wrong). For using locally stored tiles, I
think we would need something like
https://gitlab.com/IvanSanchez/Leaflet.TileLayer.MBTiles.

Out of interest, are you using tippercanoe from your command line or
do you have some code invoking it from R?

HTH,
Tim

On Wed, Mar 11, 2020 at 3:00 AM nevil amos <nevil.amos using gmail.com> wrote:
>
> I am working on a shiny/ leaflet map project which requires display of a
> large polygon dataset  (40,000 polygons ~92MB sf object).
> Needless to say it take quite a time to render the sf object and zoom in
> and out.
>
> Simplifying the polygons is not an option.
>
> leaflet.mapboxgl  https://github.com/rstudio/leaflet.mapboxgl package
> allows adding of Mapbox GL layers to a leaflet map.
>
> Since I am using my own local tiles  there should be no need for a maxbox
> access token.
>
> If possible I would like to make use of leaflet.mapboxgl: addMapboxGL() to
> display vector tiles ( as .mbtiles) of the polygons that have been pre-
> rendered from the polygon dataset using tippecanoe
> https://github.com/mapbox/tippecanoe and served using mbtileserver
> https://github.com/consbio/mbtileserver all on the same local machine.
> mbtileserver is running from the project directory, and the mbtiles are  in
> the path: <R project directory>/tilesets/mytiles.mbtiles
> I can vie the preview in the bowser a
> http://localhost:8000/services/myTiles/map
>
> however the polygons do not dispay in leaflet in r
>
> As this requires use of tippecanoe and mbtileserver I cannot post a repro,
> however below is a pared down version fo the code I am using :
>
>
> library(leaflet)
> library(leaflet.mapboxgl)
>
> options(mapbox.accessToken=NA)
>
> base_map <- leaflet() %>%
>  setView(lng = 145,lat = -37,zoom = 7)%>%
>  addProviderTiles("Esri.WorldTopoMap", group = "ESRI Topo") %>%
>   addMapox http://localhost:8000/services/myTiles ")
>
> have I simply got the wrong format/ incomplete URL fo the  addMapboxGL ? If
> so what should it be?
>
> thanks
>
>         [[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