question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data does not show in JupyterLab from local geojson file resources

See original GitHub issue

I tried to reproduce the example given in the README with an OpenMapTiles style but the data does not show, I only see the tiles. This is the result:

screenshot-2018-2-26 jupyterlab

And this is the code:

import pandas as pd
import os

from mapboxgl.utils import *
from mapboxgl.viz import *

# Load data from sample csv
data_url = 'https://raw.githubusercontent.com/mapbox/mapboxgl-jupyter/master/examples/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',
                height='400px',
                access_token='pk',
                color_property = "Avg Medicare Payments",
                color_stops = color_stops,
                center = (-95, 40),
                zoom = 3,
                #below_layer = 'waterway-label',
                style_url='https://openmaptiles.github.io/osm-bright-gl-style/style-cdn.json',
              )
viz.show()

I’m using mapboxgl 0.5.1 installed with pip 9.0.1 in Python 3.4 and latest JupyterLab.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ryanbaumanncommented, Feb 27, 2018

@scwilkinson @Juanlu001 thanks for the bug report. The method we’re using in the example is to export data for visualization to a local file points.geojson, and then load the file from the local web server which Jupyter runs from the Python kernel (localhost:8888 normally). It looks like Jupyter Lab uses a different URL path to server local files than the root web server.

As a workaround, could you try exporting the dataframe to a python dict variable, and then creating the mapboxgl.viz.CircleViz from the python variable? The approach below should be the code you need:

# Create a geojson file export from a Pandas dataframe
data = df_to_geojson(df, 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(data, 
                height='400px',
                access_token='pk',
                color_property = "Avg Medicare Payments",
                color_stops = color_stops,
                center = (-95, 40),
                zoom = 3,
                #below_layer = 'waterway-label',
                style_url='https://openmaptiles.github.io/osm-bright-gl-style/style-cdn.json',
              )
viz.show()
2reactions
jasongroutcommented, May 1, 2018

Your rendermime extension that creates the visualization has access to this resolver, so it should be able to take a filename and convert it to a url it can use. It’s passed in the arguments: https://github.com/jupyterlab/jupyterlab/blob/d740dee4980557a1d58fe0371bc467166f6cd9ac/packages/rendermime-interfaces/src/index.ts#L284 You probably want to use the getDownloadUrl function of that object: https://github.com/jupyterlab/jupyterlab/blob/d740dee4980557a1d58fe0371bc467166f6cd9ac/packages/rendermime-interfaces/src/index.ts#L332

Read more comments on GitHub >

github_iconTop Results From Across the Web

Opening too big geojson file on jupyter notebook
It will restart automatically. It's probably because the data is too big. Is there's any ways to open, I'm fine with querying etc....
Read more >
Config file and command line options - The Jupyter Notebook
The notebook server can be run with a variety of command line arguments. ... Allow requests where the Host header doesn't point to...
Read more >
Known issues for Watson Studio and supplemental services
Connected assets with shared credentials of text and JSON files are incorrectly displayed in a grid. Connected data assets for PDF files in...
Read more >
Import - Amazon SageMaker - AWS Documentation
To import a dataset into Data Wrangler from a single file that you've stored in Amazon S3: If you are not currently on...
Read more >
Jupyter tools - Mark Volkmann
JupyterLab is "Jupyter's Next-Generation Notebook Interface". ... but it is truncated and hovering over it does not show the complete path.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found