Data does not show in JupyterLab from local geojson file resources
See original GitHub issueI 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:
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:
- Created 6 years ago
- Comments:17 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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:
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