Skip to content

Commit

Permalink
Commit examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Duberstein committed Jan 24, 2020
1 parent 0dba3bf commit 5a1f35c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bindings/pydeck/examples/arc_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pydeck


DATA_URL = 'https://raw.githubusercontent.com/ajduberstein/sf_public_data/master/bay_area_commute_routes.csv'

GREEN_RGB = [0, 255, 0, 40]
RED_RGB = [240, 100, 0, 40]

arc_layer = pydeck.Layer(
'ArcLayer',
data=DATA_URL,
get_width='S000 * 2',
get_source_position=['lng_h', 'lat_h'],
get_target_position=['lng_w', 'lat_w'],
get_tilt=15,
get_source_color=RED_RGB,
get_target_color=GREEN_RGB
)

view_state = pydeck.ViewState(
latitude=37.7576171,
longitude=-122.5776844,
bearing=45,
max_pitch=360,
pitch=50,
zoom=8
)

r = pydeck.Deck(arc_layer, initial_view_state=view_state)
r.to_html('arc_layer.html', notebook_display=False)
35 changes: 35 additions & 0 deletions bindings/pydeck/examples/bitmap_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pydeck


# Map of San Francisco from 1906
IMG_URL = '"https://i.imgur.com/W95ked7.jpg"'

BOUNDS = [
[-122.52690000000051, 37.70313158980733],
[-122.52690000000051, 37.816395657523195],
[-122.34604834372873, 37.816134829424335],
[-122.34656848822227, 37.70339041384273]
]

bitmap_layer = pydeck.Layer(
'BitmapLayer',
data=None,
image=IMG_URL,
bounds=BOUNDS,
opacity=0.7
)

view_state = pydeck.ViewState(
latitude=37.7576171,
longitude=-122.5776844,
zoom=10,
bearing=-45,
pitch=60,
)

r = pydeck.Deck(
bitmap_layer,
initial_view_state=view_state,
map_style='mapbox://styles/mapbox/satellite-v9')

r.to_html('bitmap_layer.html', notebook_display=False)

0 comments on commit 5a1f35c

Please sign in to comment.