viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Nevil Amos
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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Tim Salabim
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 <[hidden email]> 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
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Nevil Amos
Hi Tim,

Thanks for you suggestions.  I have looked at the leafgl package, and yes
it does speed the rendering of  my polygons, however  it still has to
render them all, rather than using the tiling option, so is not as quick as
tiles would be ( if they worked!).

I have no problem locally serving  raster tiles to r leaflet(), this can be
achieved by running a simplserver, or the mbtilesserver, or inside a shiny
app by placing the tiles in the www directory.  The issue is getting any
vector tiles to dislay - the leaflet.mapboxgl packages is the only option I
have come across so far that suggests this may be a possibility.
I have been using tippecanoe from the linux terminal.

cheers

Nevil







On Wed, 11 Mar 2020 at 21:34, Tim Salabim <[hidden email]> wrote:

> 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 <[hidden email]> 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
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Kranstauber, Bart-2
Dear Nevil,

Regarding serving tiles locally a while ago I made a small package that can do this fully in R based on plumbr (https://gitlab.com/bartk/starsTileServer/). It is not really finished yet but I have found it to be a useful way to avoid prerendering a lot of tiles. I think it is most useful for raster data but if you can create tiles from your input data you can provide a custom function to generate tiles. If you find it useful I can wrap it up a bit more.

Best

Bart
________________________________________
From: R-sig-Geo <[hidden email]> on behalf of nevil amos <[hidden email]>
Sent: 12 March 2020 00:14:04
To: Tim Salabim
Cc: r-sig-geo
Subject: Re: [R-sig-Geo] viewing locally hosted mbtiles vector tiles using leaflet.mapboxgl?

Hi Tim,

Thanks for you suggestions.  I have looked at the leafgl package, and yes
it does speed the rendering of  my polygons, however  it still has to
render them all, rather than using the tiling option, so is not as quick as
tiles would be ( if they worked!).

I have no problem locally serving  raster tiles to r leaflet(), this can be
achieved by running a simplserver, or the mbtilesserver, or inside a shiny
app by placing the tiles in the www directory.  The issue is getting any
vector tiles to dislay - the leaflet.mapboxgl packages is the only option I
have come across so far that suggests this may be a possibility.
I have been using tippecanoe from the linux terminal.

cheers

Nevil







On Wed, 11 Mar 2020 at 21:34, Tim Salabim <[hidden email]> wrote:

> 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 <[hidden email]> 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
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo