mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
661 stars 136 forks source link

Issue Trying To Run Python Mapbox Example #152

Closed dljthomas1 closed 5 years ago

dljthomas1 commented 5 years ago

Hi folks - I seem to be having a variant of this issue (https://github.com/mapbox/mapboxgl-jupyter/issues/10).

I am trying to run the example from here. The map is displaying fine. However, the points/data are missing.

Screenshot 2019-04-17 at 11 18 13

Some points worth mentioning:

Screenshot 2019-04-17 at 11 21 59

Thanks in advance for your help!

Also see my code below:

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)

# Must be a public token, starting with `pk`
token = 'pk.eyJ1IjoiYnVzaW5lc3NvZmNpdGllcyIsImEiOiJjanVqdHF0NHQxazczNGFxamZydmQ2NmRzIn0.oZStPDr7CsZIFTemgdr-cw'

# 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 = 1,
                below_layer = 'waterway-label'
              )
viz.show()
dljthomas1 commented 5 years ago

Ignore - Found solution here: https://github.com/mapbox/mapboxgl-jupyter/issues/50