-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Using local image file with BitmapLayer doesn't work - Pydeck #4977
Comments
An easy test is to paste your image string into the browser's location bar and see if it displays. If not, then it is not a valid image. |
You can base64 encode that image and then wrap the encoded data in quotes to indicate to pydeck that it's a string literal. import pydeck as pdk
# base64-encoded image string of a red dot
IMG_URL = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="'
# Specifies the corners of the image bounding box
BOUNDS = [
[-122.52690000000051, 37.70313158980733],
[-122.52690000000051, 37.816395657523195],
[-122.34604834372873, 37.816134829424335],
[-122.34656848822227, 37.70339041384273],
]
bitmap_layer = pdk.Layer("BitmapLayer", data=None, image=IMG_URL, bounds=BOUNDS, opacity=0.7)
view_state = pdk.ViewState(latitude=37.7576171, longitude=-122.5776844, zoom=10, bearing=-45, pitch=60,)
r = pdk.Deck(bitmap_layer, initial_view_state=view_state, map_style=pdk.map_styles.SATELLITE)
r.to_html() Currently your image asset must be served or passed as a base64-encoded string. Then the URL or encoded string must be wrapped in quotes, e.g., |
Thanks a lot @ajduberstein , wrapping the encoded data in quotes solved my issue. This was the missing info for me. |
Description
Trying to load a bitmap layer using pydeck from local image file. Setting the image argument to point to the full path of the image results in a black image. I tried to use the pydeck example and just downloaded the image from the url and pointed to where it is locally. Using the URL works but local file shows black image.
I tried to encode the image as base64 using below line, in this case no thing shows up.
Steps to produce the issue
Environment (
The text was updated successfully, but these errors were encountered: