Reputation: 11
I have a large JSON with the data for dozens of locations, which I am trying to plot on a map using pydeck. The output map doesn't display any points in the area, and I'm not sure why.
Here is my code:
import pydeck as pdk
data = insert local json here
layer = pdk.Layer(
"ScatterplotLayer",
data,
pickable=True,
opacity=0.8,
stroked=True,
filled=True,
radius_scale=6,
radius_min_pixels=1,
radius_max_pixels=100,
line_width_min_pixels=1,
get_position=['lon', 'lat'],
get_fill_color=[255, 140, 0],
get_line_color=[0, 0, 0],
)
# Set the viewport location
view_state = pdk.ViewState(latitude=59.10816422596582, longitude=18.384297022641775, zoom=9, bearing=0, pitch=0)
# Render
r = pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip={"text": "{name}"})
r.to_html("scatterplot_layer.html")
The JSON is huge so here is a sample of it:
{'elements': [{'id': 358356239,
'lat': 59.3207673,
'lon': 18.1549076,
'tags': {'man_made': 'lighthouse',
'name': 'Blockhusudden',
'seamark:light:1:character': 'Fl',
'seamark:light:1:colour': 'red',
'seamark:light:1:group': '2',
'seamark:light:1:height': '6',
'seamark:light:1:period': '6',
'seamark:light:1:range': '4',
'seamark:light:1:sector_end': '222',
'seamark:light:2:character': 'Fl',
'seamark:light:2:colour': 'green',
'seamark:light:2:group': '2',
'seamark:light:2:height': '6',
'seamark:light:2:period': '6',
'seamark:light:2:range': '3',
'seamark:light:2:sector_end': '244',
'seamark:light:2:sector_start': '222',
'seamark:light:3:character': 'Fl',
'seamark:light:3:colour': 'white',
'seamark:light:3:group': '2',
'seamark:light:3:height': '6',
'seamark:light:3:period': '6',
'seamark:light:3:range': '6',
'seamark:light:3:sector_end': '86.5',
'seamark:light:3:sector_start': '244',
'seamark:light:reference': 'C 6558',
'seamark:name': 'Blockhusudden',
'seamark:type': 'light_minor',
'wikidata': 'Q10431416'},
'type': 'node'}]
}
I am aware that my JSON has single quotes instead of double quotes, but this is the data I need to work with. The issue persists even if the single quotes are replaced with double quotes.
Upvotes: 1
Views: 445