Help with getColor and related

The admittedly totally undocumented answer to this is to add columns named ‘colorR’, ‘colorG’ and ‘colorB’ as shown in this gist and reproduced here:

import streamlit as st
import pandas as pd
import numpy as np
 
n_points = 1000
sf_lat, sf_lon = 37.76, -122.4
map_data = pd.DataFrame({
    'lat': np.random.randn(n_points) / 50 + sf_lat,
    'lon': np.random.randn(n_points) / 50 + sf_lon,
    'colorR': np.random.uniform(size=n_points, high=255.0),
    'colorG': np.random.uniform(size=n_points, high=255.0),
    'colorB': np.random.uniform(size=n_points, high=255.0),
})
 
st.deck_gl_chart(
    viewport={
        'latitude': map_data['lat'].median(),
        'longitude': map_data['lon'].median(),
        'zoom': 11,
        'pitch': 50,
        'opacity': 0.1
    },
    layers = [{
        'data': map_data,
        'type': 'ScatterplotLayer'
}])

To see this gist in action, please run:

streamlit run https://gist.githubusercontent.com/treuille/b95f5cc9bb521bd30adc27cd578ca935/raw

and you will see something like:

Does that work for you?

1 Like