Spaces:
Sleeping
Sleeping
Birgir
commited on
Commit
·
45d34ef
1
Parent(s):
96c9276
adedd stops and dropdown
Browse files- app/app.py +27 -12
- app/borgarlina3_leaflet.py +1 -1
app/app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import faicons as fa
|
2 |
|
3 |
-
from ipyleaflet import Map
|
4 |
|
|
|
5 |
from datetime import datetime
|
6 |
# Load data and compute static values
|
7 |
from borgarlina3_leaflet import create_map, load_and_preprocess_data
|
@@ -11,14 +12,21 @@ from shinywidgets import render_widget
|
|
11 |
from shiny import reactive, render
|
12 |
from shiny.express import input, ui
|
13 |
|
14 |
-
def generateStops():
|
15 |
-
geojson_file = "../given_data/cityline_geojson/
|
16 |
pop_file = "../given_data/ibuafjoldi.csv"
|
17 |
smallarea_file = "../given_data/smasvaedi_2021.json"
|
18 |
dwellings_file = "../given_data/ibudir.csv"
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
bill_rng = (min(tips.total_bill), max(tips.total_bill))
|
24 |
|
@@ -27,7 +35,8 @@ ui.page_opts(title="Borgarlínan", fillable=True)
|
|
27 |
|
28 |
with ui.sidebar(open="open"):
|
29 |
|
30 |
-
ui.
|
|
|
31 |
ui.input_text("inputParam", "Param", "")
|
32 |
|
33 |
ui.input_checkbox_group(
|
@@ -57,9 +66,9 @@ with ui.layout_columns(col_widths=[8, 4]):
|
|
57 |
|
58 |
@render_widget
|
59 |
def map():
|
60 |
-
return Map(
|
61 |
|
62 |
-
with ui.layout_column_wrap(width="250px"):
|
63 |
with ui.card(full_screen=False):
|
64 |
ui.card_header("Stop Data")
|
65 |
@render_widget
|
@@ -88,7 +97,7 @@ with ui.layout_columns(col_widths=[8, 4]):
|
|
88 |
{},
|
89 |
width="250px",
|
90 |
height="100px"
|
91 |
-
)
|
92 |
|
93 |
|
94 |
ui.include_css(app_dir / "styles.css")
|
@@ -107,7 +116,13 @@ def tips_data():
|
|
107 |
|
108 |
|
109 |
@reactive.effect
|
110 |
-
@reactive.event(input.reset)
|
111 |
def _():
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import faicons as fa
|
2 |
|
3 |
+
from ipyleaflet import Map, Marker, LayerGroup
|
4 |
|
5 |
+
import geopandas as gpd
|
6 |
from datetime import datetime
|
7 |
# Load data and compute static values
|
8 |
from borgarlina3_leaflet import create_map, load_and_preprocess_data
|
|
|
12 |
from shiny import reactive, render
|
13 |
from shiny.express import input, ui
|
14 |
|
15 |
+
def generateStops(year):
|
16 |
+
geojson_file = f"../given_data/cityline_geojson/cityline_{year}.geojson"
|
17 |
pop_file = "../given_data/ibuafjoldi.csv"
|
18 |
smallarea_file = "../given_data/smasvaedi_2021.json"
|
19 |
dwellings_file = "../given_data/ibudir.csv"
|
20 |
|
21 |
+
gpdStops, _, _ = load_and_preprocess_data(geojson_file, pop_file, smallarea_file, dwellings_file)
|
22 |
+
|
23 |
+
points = []
|
24 |
+
|
25 |
+
# Assuming your GeoDataFrame is named 'gdf'
|
26 |
+
for _, row in gpdStops.iterrows():
|
27 |
+
point = row["geometry"]
|
28 |
+
points.append((point.y, point.x))
|
29 |
+
return points
|
30 |
|
31 |
bill_rng = (min(tips.total_bill), max(tips.total_bill))
|
32 |
|
|
|
35 |
|
36 |
with ui.sidebar(open="open"):
|
37 |
|
38 |
+
ui.input_select("year", "Year:",
|
39 |
+
{2025: "2025", 2029: "2029", 2030: "2030"})
|
40 |
ui.input_text("inputParam", "Param", "")
|
41 |
|
42 |
ui.input_checkbox_group(
|
|
|
66 |
|
67 |
@render_widget
|
68 |
def map():
|
69 |
+
return Map(center=(64.11,-21.90), zoom=11.5)
|
70 |
|
71 |
+
'''with ui.layout_column_wrap(width="250px"):
|
72 |
with ui.card(full_screen=False):
|
73 |
ui.card_header("Stop Data")
|
74 |
@render_widget
|
|
|
97 |
{},
|
98 |
width="250px",
|
99 |
height="100px"
|
100 |
+
)'''
|
101 |
|
102 |
|
103 |
ui.include_css(app_dir / "styles.css")
|
|
|
116 |
|
117 |
|
118 |
@reactive.effect
|
|
|
119 |
def _():
|
120 |
+
year = input.year()
|
121 |
+
stops = generateStops(year)
|
122 |
+
markers = []
|
123 |
+
for i in stops:
|
124 |
+
marker = Marker(location=i)
|
125 |
+
markers.append(marker)
|
126 |
+
|
127 |
+
layerGroup = LayerGroup(layers=markers)
|
128 |
+
map.widget.add(layerGroup)
|
app/borgarlina3_leaflet.py
CHANGED
@@ -74,7 +74,7 @@ def create_map(lina1_wgs84, all_dwellings_smallarea):
|
|
74 |
return m
|
75 |
|
76 |
def main():
|
77 |
-
geojson_file = "../given_data/cityline_geojson/
|
78 |
pop_file = "../given_data/ibuafjoldi.csv"
|
79 |
smallarea_file = "../given_data/smasvaedi_2021.json"
|
80 |
dwellings_file = "../given_data/ibudir.csv"
|
|
|
74 |
return m
|
75 |
|
76 |
def main():
|
77 |
+
geojson_file = "../given_data/cityline_geojson/cityline_2030.geojson"
|
78 |
pop_file = "../given_data/ibuafjoldi.csv"
|
79 |
smallarea_file = "../given_data/smasvaedi_2021.json"
|
80 |
dwellings_file = "../given_data/ibudir.csv"
|