mapbox / mapbox/mapboxgl-jupyter

Example displays base map but not points

Open
#182 2 comments 8 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
681
Forks
137
PR merge metrics
No merged PRs in 30d

Description

mapboxgl 0.10.2 in a Python 3.8.6 kernel in Jupyter:

Code

```python
with open('mapbox_token.txt','r') as f:
# Must be a public token, starting with `pk`
token = f.read().strip()

import os

import pandas as pd

from mapboxgl.utils import create_color_stops, df_to_geojson
from mapboxgl.viz import CircleViz

# Load data from sample csv
data_url = 'https://raw.githubusercontent.com/mapbox/mapboxgl-jupyter/master/examples/data/points.csv'
df = pd.read_csv(data_url)

# Create a geojson file export from a Pandas dataframe
df_to_geojson(df, filename='points.geojson',
properties=['Avg Medicare Payments', 'Avg Covered Charges', 'date'],
lat='lat', lon='lon', precision=3)

# Generate data breaks and color stops from colorBrewer
color_breaks = [0,10,100,1000,10000]
color_stops = create_color_stops(color_breaks, colors='YlGnBu')

# Create the viz from the dataframe
viz = CircleViz('points.geojson',
access_token=token,
height='400px',
color_property = "Avg Medicare Payments",
color_stops = color_stops,
center = (-95, 40),
zoom = 3,
below_layer = 'waterway-label'
)
viz.show()
```

![mapboxgl jupyter widget showing base map but no points](https://user-images.githubusercontent.com/465045/107054518-3d8bd500-679e-11eb-868d-14e8afb42091.png)

I expected to see points on the map, like in the screenshot in the docs:
![jupyter screenshot from docs showing points on a map](https://user-images.githubusercontent.com/465045/107054887-aa9f6a80-679e-11eb-85fb-9031f646d18b.png)

`df` looks vaguely reasonable / non-empty:
![jupyter widget showing geojson dataframe](https://user-images.githubusercontent.com/465045/107054677-70ce6400-679e-11eb-8486-7f22352e94cc.png)

Also note the `UserWarning` mentioned in https://github.com/mapbox/mapboxgl-jupyter/issues/150#issuecomment-475405241, not sure if it's relevant:
```
/usr/local/lib/python3.8/site-packages/IPython/core/display.py:717: UserWarning: Consider using IPython.display.IFrame instead
warnings.warn("Consider using IPython.display.IFrame instead")
```

What am I missing? Thanks.

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Python code in a Jupyter kernel and inspect the generated points.geojson. Trace how CircleViz consumes that file and renders points, using the mapboxgl.utils and mapboxgl.viz entry points shown in the example. Done means the example displays the point features as expected alongside the base map.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, pandas, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.