Create an interactive 3D model of the solar system, with the real planets of the solar system.
Drop files here
or click to upload
import streamlit as st
import pydeck as pdk
import pandas as pd
import numpy as np
# Solar system data
planets_data = {
'Planet': ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'],
'Distance from Sun (km)': [57909176, 108208930, 149598262, 227943824, 778340821, 1426666400, 2870658186, 4498396441],
}
# Convert to DataFrame
planets_df = pd.DataFrame(planets_data)
# Calculate latitude and longitude (simplified representation)
planets_df['lat'] = np.random.uniform(-90, 90, len(planets_df))
planets_df['lon'] = np.random.uniform(-180, 180, len(planets_df))
# Create a PyDeck chart
view_state = pdk.ViewState(
longitude=0,
latitude=0,
zoom=1,
pitch=0
)
layers = [
pdk.Layer(
'ScatterplotLayer',
data=planets_df,
get_position='[lon, lat]',
get_radius='Distance from Sun (km) / 1000000',
get_color='[255, 255, 0]',
pickable=True,
),
]
# Render the chart
st.pydeck_chart(pdk.Deck(
layers=layers,
initial_view_state=view_state,
map_style='mapbox://styles/mapbox/light-v9'
))
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?