Mapboxgl Python Library for location data visualization

https://github.com/mapbox/mapboxgl-jupyter

Requirements

These examples require the installation of the following python modules

pip install mapboxgl
In [ ]:
import os
from mapboxgl.viz import RasterTilesViz

# Set Mapbox Acces Token; Must be a public token, starting with `pk`
token = os.getenv('MAPBOX_ACCESS_TOKEN')

Create a map with raster tiles from OpenStreetMap.org

In [ ]:
tiles_url = 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'

# Create an empty style
style = {'version': 8, 'sources': {}, 'layers': []}

viz = RasterTilesViz(tiles_url, 
                     access_token=token,
                     tiles_size=256,
                     height='500px', 
                     zoom=3, 
                     style=style)
viz.show()

Display raster tiles on a mapbox basemap

In [ ]:
tiles_url = 'https://cogeo.remotepixel.ca/tiles/{z}/{x}/{y}.jpg?tile=256&nodata=0&url=http://oin-hotosm.s3.amazonaws.com/594ab0ba1b114600111194a3/0/d66720c4-148c-4e11-9d54-4ae2a6ba6351.tif'

# Define the tile endpoint bounds
tiles_bounds = [124.97480681619507, 10.876763902260592, 124.99391704636035, 10.888369402219947]
tiles_center = [124.9843619312777, 10.88256665224027]

viz = RasterTilesViz(tiles_url, 
                     access_token=token,
                     tiles_size=256,
                     tiles_bounds=tiles_bounds,
                     height='500px', 
                     center=tiles_center,
                     tiles_minzoom=13,
                     tiles_maxzoom=18,
                     zoom=15,
                     below_layer='waterway-label')
viz.show()