https://github.com/mapbox/mapboxgl-jupyter
These examples require the installation of the following python modules
pip install mapboxgl rio-glui==1.0.0
import os
from rio_glui.server import TileServer
from rio_glui.raster import RasterTiles
from mapboxgl.utils import *
from mapboxgl.viz import *
token = os.getenv('MAPBOX_ACCESS_TOKEN')
# Create local tile server using `rio-glui`
url = 'https://oin-hotosm.s3.amazonaws.com/5ac626e091b5310010e0d482/0/5ac626e091b5310010e0d483.tif'
# Create raster tile object
# More info: https://github.com/mapbox/rio-glui/blob/master/rio_glui/raster.py#L16-L44
raster = RasterTiles(url, indexes=(2, 1, 3))
# Create local tile server
# More info: https://github.com/mapbox/rio-glui/blob/master/rio_glui/server.py#L21-L56
ts = TileServer(raster)
# Start tile server
ts.start()
# Initialize RasterTiles Viz by passing our local tile server url `ts.get_tiles_url`
viz = RasterTilesViz(ts.get_tiles_url(),
tiles_bounds=ts.get_bounds(),
center=ts.get_center(),
access_token=token,
height='1000px',
zoom=13)
viz.show()
# We need to stop the previous server in order to create a new one
ts.stop()
raster = RasterTiles(url, indexes=(1,2,3))
ts = TileServer(raster)
ts.start()
viz = RasterTilesViz(ts.get_tiles_url(),
tiles_bounds=ts.get_bounds(),
center=ts.get_center(),
access_token=token,
height='1000px',
zoom=13)
viz.show()