Reputation: 1
everyone ! I'm trying to understand how to make maps with PyDeck, but i have a recurring error message : " TypeError: init() got an unexpected keyword argument 'mapbox_key'".
After hours, I don't know how to resolve it ? have you any idea ?
code :
Python 3.9.12
version de Pydeck : 0.8.0
version de pandas: 1.4.2
version de vega_datasets : 0.9.0
version de ipywidgets : 7.6.5
import pydeck as pdk
import pandas as pd
from vega_datasets import data as vds
import ipywidgets
from palettable.cartocolors.sequential import BrwnYl_3
import json
# Public API key
MAPBOX_API_KEY = "pk.eyJ1IjoiZXphYW45MDIiLCJhIjoiY2xhdHI4NzI3MDQwazNwcDg1bDdyN3ZzMCJ9.8BOAE-IFmp6PeellMppXsA"
# data
data = 'https://raw.githubusercontent.com/groundhogday321/dataframe-datasets/master/fake_commute_data.csv'
commute_pattern = pd.read_csv(data)
print(commute_pattern.head(2))
# view (location, zoom level, etc.)
view = pdk.ViewState(latitude=32.800382, longitude=-97.040728, pitch=50, zoom=9)
# layer
# from home (orange) to work (purple)
arc_layer = pdk.Layer('ArcLayer',
data=commute_pattern,
get_source_position=['from_lon', 'from_lat'],
get_target_position=['to_lon', 'to_lat'],
get_width=5,
get_tilt=15,
# RGBA colors (red, green, blue, alpha)
get_source_color=[255, 165, 0, 80],
get_target_color=[128, 0, 128, 80])
# render map
arc_layer_map = pdk.Deck(map_style='mapbox://styles/mapbox/light-v10',
layers=arc_layer,
initial_view_state=view,
mapbox_key=MAPBOX_API_KEY)
# display and save map (to_html(), show())
arc_layer_map.to_html(r'C:\Users\Admin loc\OneDrive\Bureau\arc_layer_map.html')
arc_layer_map.show()
I tried to load my Mapbox token and run this tutorial...
Upvotes: 0
Views: 1170
Reputation: 27614
According to the documentation pdk.Deck
doesn't take a mapbox_key
argument.
You probably need to provide it like this:
arc_layer_map = pdk.Deck(...
api_keys={'mapbox': MAPBOX_API_KEY})
Upvotes: 0