-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
issues rendering maplibre pydeck layers #833
Comments
one more footnote, trying some other types like scatterplot things seem to work as expected. (again based on pydeck examples
|
This is an example using py-maplibre directly without leafmap. Got the same error that the from maplibre import MapOptions
from maplibre.basemaps import Carto
from maplibre.controls import NavigationControl
from maplibre.ipywidget import MapWidget as Map
m = Map(
MapOptions(
style=Carto.POSITRON,
center=(-122.4, 37.74),
zoom=12,
hash=True,
pitch=40,
)
)
m.add_control(NavigationControl())
deck_grid_layer = {
"@@type": "H3HexagonLayer",
"id": "my-layer",
"data": 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf.h3cells.json',
"getHexagon": "@@=hex",
}
m.add_deck_layers([deck_grid_layer], tooltip="Number of points: {{ count }}")
m |
Closing this one as it is an upstream issue reported at eoda-dev/py-maplibregl#99. |
@giswqs This issue is now fixed upstream. Additionally, upstream, this works when |
Awesome! PR is welcome |
Thanks @giswqs ! I'll take a go at this! |
@giswqs as usual the problem was between screen and keyboard. After the upstream fixes (and maybe even before?) we can pass pydeck layer directly, instead of the funky This means I can just paste the standard/already working pydeck layer directly into leafmap and viola! import leafmap.maplibregl as leafmap
import pandas as pd
import pydeck as pdk
url = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf.h3cells.json"
h3cells = pd.read_json(url, orient='records')
m = leafmap.Map(style="positron", center=(-122.4, 37.74), zoom=10, pitch=30)
layer = pdk.Layer(
"H3HexagonLayer",
h3cells,
get_hexagon="hex",
get_fill_color="[255 - count, 255, count]",
extruded=True,
get_elevation="count",
elevation_scale=20,
)
# leafmap's maplibre engine just renders the pydeck layer magically:
m.add_deck_layers([layer])
m This is so very nice! |
Wow, that's great to know! Much more pythonic now. |
Environment Information
Description
This minimal pure-pydeck example (based on pydeck docs) works:
But I try translating this to leafmap:
The map renders but the data layer isn't drawn.
I have noticed that pydeck/deck-gl is very sensitive to types, for instance, a slightly modified version of the pydeck code will fail in the same silent way (map but no data layer) because elevation_scale is given as a string instead of a numeric:
I can confirm the example in the leafmap tutorial works for me though.
I did notice it no longer works if
data
is given as a local geojson file or as a pandas data.frame, though pydeck supports those options, but I guess that makes sense since I gather leafmap maplibre doesn't use pydeck but goes to deck.gl via libremap bindings instead. So I've used URLs in my example above, but no luck.From what I understand,
@@=
is just required on the 'getter' methods,get*
.The text was updated successfully, but these errors were encountered: