New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pydeck and @deck.gl/json error: No registered class of type Feature #3836
Comments
Thanks for reporting. Fixing this bug that will require changes to how we generate intermediate JSON as described in #3767. In the meantime, if you don't need to process the GeoJSON in Python, can you just pass the URL to the layer?
This way the GeoJSON won't be part of the JSON sent between Python and the browser but instead loaded directly into the browser without any intermediate processing. Passing URL would work in the JavaScript API so I assume it should work in pydeck as well... @ajduberstein ? |
@ibgreen The problem is that I load the GeoJson from a file, it's not hosted anywhere. Is there another workaround to use files instead of urls? |
@pancho111203 In that case I can't think of an easy workaround. The problem that we do special processing on JSON My current sense is that we should be able to fix this in one of our weekly deck.gl v7.3 patch releases, i.e. you should not have to wait for a new major release to get this fixed. |
Thank you for reporting this, @pancho111203. I've written a demo notebook here named after this issue–click import pandas as pd
import pydeck
# Load in the JSON data
DATA_URL = 'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/geojson/vancouver-blocks.json'
json = pd.read_json(DATA_URL)
polygon_df = pd.DataFrame()
# Parse the geometry out in Pandas and pass it to deck.gl's PolygonLayer
# I'll make the next release such that you don't have to do this
# manual extraction.
polygon_df['coordinates'] = json['features'].apply(lambda row: row['geometry']['coordinates'])
polygon_df['valuePerSqm'] = json['features'].apply(lambda row: row['properties']['valuePerSqm'])
polygon_df['growth'] = json['features'].apply(lambda row: row['properties']['growth'])
polygon_df.head()
INITIAL_VIEW_STATE = pydeck.ViewState(
latitude=49.254,
longitude=-123.13,
zoom=11,
max_zoom=16,
pitch=45,
bearing=0
)
geojson = pydeck.Layer(
'PolygonLayer',
polygon_df,
opacity=0.8,
get_polygon='coordinates',
stroked=False,
filled=True,
extruded=True,
wireframe=True,
get_elevation='valuePerSqm / 20',
get_fill_color='[255, 255, growth * 255]',
get_line_color=[255, 255, 255],
pickable=True
)
r = pydeck.Deck(
layers=[geojson],
initial_view_state=INITIAL_VIEW_STATE)
r.to_html(iframe_width=1000) Unambiguously we should have support for parsing GeoJSON built into pydeck–expect this in the next release. |
Great, I'll use that workaround in the meantime. Thank you both for your help! |
This is fixed in pydeck 0.2.0–please update your installation. Feel free to re-open this issue if something doesn't work as expected. |
Description
In PyDeck, when initializing a GeoJsonLayer with a features object, we get a warning and no polygons are displayed in the map.
Repro Steps
The text was updated successfully, but these errors were encountered: