Created
November 20, 2019 18:17
-
-
Save jrhone/a45fa7ae88f385ae1fa1ddb1d7adfa63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
# Step 1: CREATE A MAP DATAFRAME WITH red green AND blue COLUMNS | |
sf_lat, sf_lon = [37.76, -122.4] | |
radius = 50 | |
df = pd.DataFrame( | |
np.random.randn(1000, 2) / [radius, radius] + [sf_lat, sf_lon], | |
columns=['lat', 'lon']) | |
lat_min, lat_max = df.lat.min(), df.lat.max() | |
lon_min, lon_max = df.lon.min(), df.lon.max() | |
df['red'] = 255.0 * (df.lat - lat_min) / (lat_max - lat_min) | |
df['green'] = 128.0 | |
df['blue'] = 255.0 * (df.lon - lon_min) / (lon_max - lon_min) | |
# Step 2: DISPLAY IT IN DECKGL | |
st.write(df) | |
st.deck_gl_chart( | |
viewport={ | |
'latitude': sf_lat, | |
'longitude': sf_lon, | |
'zoom': 11, | |
'pitch': 0, | |
}, | |
layers=[ | |
{ | |
'type': 'ScatterplotLayer', | |
'data': df, | |
'getColorR': 'red', | |
'getColorG': 'green', | |
'getColorB': 'blue', | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment