Py.Cafe

Sindhup24/

solara-altair-geoplot

Geoplot Visualization with Altair and Solara

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import solara
import altair as alt
from vega_datasets import data

# Load data
countries = alt.topo_feature(data.world_110m.url, 'countries')

# Create map
map_chart = alt.Chart(countries).mark_geoshape().encode(
    color='properties.name:N'
).project(
    'naturalEarth1'
).properties(
    width=800,
    height=400
)

# Create Solara app
@solara.component
def Page():
    solara.Markdown("## World Map")
    solara.Html(map_chart.to_html())  # Display the Altair map

app = solara.App(Page)

# Run the Solara app
if __name__ == "__main__":
    solara.run(app, title="Altair Map")