Issue Trying To Run Python Mapbox Example
dljthomas1 opened this issue · 1 comments
dljthomas1 commented
Hi folks - I seem to be having a variant of this issue (#10).
I am trying to run the example from here. The map is displaying fine. However, the points/data are missing.
Some points worth mentioning:
-
I've ran this in Google Colab and on my own Jupyter machine to make sure its not an issue with the environment. I've also ran in Python 2 and 3.
-
There is a javascript error in the console whenever I run the code. See below.
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
Ignore - Found solution here: #50