Skip to content

Use Mapbox GL JS to visualize data in a Python Jupyter notebook

License

Notifications You must be signed in to change notification settings

cuulee/mapboxgl-jupyter

 
 

Repository files navigation

mapboxgl-jupyter

Build Status Coverage Status PyPI version

Create Mapbox GL JS data visualizations natively in your Jupyter Notebook workflows with Python, GeoJSON and Pandas dataframes. Mapboxgl aims to be a data visualization focused mapping library built on top of the Mapbox GL JS SDK, similar to Folium built on top of Leaflet.

Currently supported map visualization types:

  1. Circles
  2. Graduated Circles
  3. Heatmaps

image

Installation

pip install mapboxgl

Development

Install the python library locally with pip:

pip install -e .

To run tests use pytest:

pytest

To run the jupiter examples,

  1. cd examples
  2. pip install jupyter
  3. jupyter notebook

Usage

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.

Status

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.

Running the Examples

  1. Install Python3.4+
  2. pip install mapboxgl
  3. cd to /example directory of mapboxgl-jupyter repo
  4. Open the test-python.ipynb workbook
  5. Put your Mapbox GL Access Token (it's free for developers!) into the notebook, cell 4.
  6. Run all cells in the notebook and enjoy the interactive maps.

About

Use Mapbox GL JS to visualize data in a Python Jupyter notebook

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 85.5%
  • HTML 14.5%