Create Mapbox GL JS data visualizations natively in your Jupyter Notebook workflows with Python, GeoJSON and Pandas dataframes.
pip install mapboxgl
Install the python locally with pip:
pip install -e .
To run tests use pytest:
pytest
mapboxgl
visualizations take GeoJSON data as input.
You can convert pandas
dataframes to a GeoJSON feature collection:
data = df_to_geojson(df, ['Avg Total Payments'],
lat='latitude', lon='longitude')
Using the CircleViz
visualization to view the data with
a color ramp for the total payment column. Within a Jupyter
notebook:
viz = CircleViz(data,
color_property='Avg Total Payments',
color_stops=color_stops,
access_token=YOUR_PUBLIC_ACCESS_TOKEN)
viz.show()
The examples/
directory contains Jupyter notebooks
demonstrating more advanced usage.
Under heavy development. As we move towards a 1.0 release, expect
API changes. If you're interested in contributing and are
curious about the direction of the project, check out ROADMAP.md
.
- Install Python3.4+
pip install mapboxgl
- cd to /example directory of mapboxgl-jupyter repo
- Open the
test-python.ipynb
workbook - Put your Mapbox GL Access Token (it's free for developers!) into the notebook, cell 4.
- Run all cells in the notebook and enjoy the interactive maps.
If you have access to Mapbox Atlas Server on your enterprise network, simply pass in your map stylesheet from your local Atlas URL as opposed to a mapbox://
URL in cell 214.
# Put your Your Mapbox Access token here
# https://www.mapbox.com/help/how-access-tokens-work/
# If you use Mapbox Atlas, this isn't required. Leave as an empty string.
mapbox_accesstoken = ''
# Map Style. Point this to a local style, or a custom style on your Mapbox account or Atlas instance
mapStyle = "myAtlasUrl:myAtlasPort:/myStylesheetLocaiton"