rishabh99 commited on
Commit
8a507f6
·
verified ·
1 Parent(s): 1f0ed7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -12
app.py CHANGED
@@ -4,14 +4,24 @@ import plotly.express as px
4
  import plotly.graph_objs as go
5
 
6
  # Load the CSV file
7
- file = "brick_kiln_lucknow_v1.csv" # Replace with the correct path to your CSV file
 
 
 
 
 
 
 
 
 
 
8
  data = pd.read_csv(file)
9
 
10
  # Streamlit app title
11
  st.markdown("<h2 style='text-align: center;'>Brick Kiln Location and Conversion Visualization</h2>", unsafe_allow_html=True)
12
 
13
  # Slider to select the year
14
- year_selected = st.slider("Select the Year", min_value=int(data["Year made"].min()), max_value=int(data["fcb to zigzag"].max()), value=int(data["Year made"].min()), step=1)
15
  filtered_data = data[data["Year made"] <= year_selected]
16
 
17
  # # Calculate the change in fcbk to zigzag by checking the 'fcb to zigzag' column
@@ -61,7 +71,7 @@ fig_filtered = px.scatter_mapbox(
61
  mapbox_style="carto-positron",
62
  hover_name="Type",
63
  zoom=8.5,
64
- center={"lat": 26.8467, "lon": 80.9462},
65
  title=f"Brick Kiln Locations and Status up to Year {year_selected}",
66
  height=600,
67
  width=600
@@ -82,12 +92,33 @@ with col1:
82
  with col2:
83
  st.subheader("Yearly Kiln Made")
84
  st.dataframe(yearly_summary)
85
-
86
- # Historical data for brick kilns
87
- years = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]
88
- brick_kilns_total = [117, 314, 376, 396, 408, 432, 433, 454, 461, 466, 470, 477, 478]
89
- brick_kilns_fcb = [52, 127, 159, 171, 178, 191, 192, 206, 208, 209, 209, 209, 209]
90
- brick_kilns_zigzag = [65, 187, 217, 225, 230, 241, 241, 248, 253, 257, 261, 268, 269]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  # Creating the line plot for the number of brick kilns over the years
93
  fig_line = go.Figure()
@@ -98,17 +129,18 @@ fig_line.add_trace(go.Scatter(x=years, y=brick_kilns_zigzag, mode='lines+markers
98
 
99
  # Adding labels and title to the line chart
100
  fig_line.update_layout(
101
- title="Number of Brick Kilns Over Years in Lucknow",
102
  xaxis_title="Years",
103
  yaxis_title="Number of Brick Kilns",
104
- yaxis=dict(tickmode='linear', tick0=0, dtick=25,showgrid=False),
105
  width=900
106
  )
107
 
108
  # Adding vertical line for the selected year
109
  fig_line.add_vline(x=year_selected, line_dash="dash", line_color="black", annotation_text=f"Year {year_selected}")
 
110
  # Displaying the line chart
111
- st.plotly_chart(fig_line)
112
 
113
  # # Emission factors
114
  # emission_factor_pm25_fcb = 15000 * 6.8 # grams/day per FCB kiln
 
4
  import plotly.graph_objs as go
5
 
6
  # Load the CSV file
7
+ # file = "/home/rishabh.mondal/Brick-Kilns-project/albk_rishabh/albk_v2/YOLO_LOCALIZATION/Compliance-app/brick_kiln_lucknow_v1.csv" # Replace with the correct path to your CSV file
8
+
9
+ # Dropdown to select the location
10
+ location = st.selectbox("Select Location", ["Lucknow", "Delhi"])
11
+
12
+ # Determine the file path based on selection
13
+ if location == "Lucknow":
14
+ file = "brick_kiln_lucknow_v1.csv"
15
+ else:
16
+ file = "brick_kiln_delhi_v1.csv"
17
+
18
  data = pd.read_csv(file)
19
 
20
  # Streamlit app title
21
  st.markdown("<h2 style='text-align: center;'>Brick Kiln Location and Conversion Visualization</h2>", unsafe_allow_html=True)
22
 
23
  # Slider to select the year
24
+ year_selected = st.slider("Select the Year", min_value=int(data["Year made"].min()), max_value=int(data["Year made"].max()), value=int(data["Year made"].min()), step=1)
25
  filtered_data = data[data["Year made"] <= year_selected]
26
 
27
  # # Calculate the change in fcbk to zigzag by checking the 'fcb to zigzag' column
 
71
  mapbox_style="carto-positron",
72
  hover_name="Type",
73
  zoom=8.5,
74
+ center={"lat": 26.8467, "lon": 80.9462} if location == "Lucknow" else {"lat": 28.7041, "lon": 77.1025},
75
  title=f"Brick Kiln Locations and Status up to Year {year_selected}",
76
  height=600,
77
  width=600
 
92
  with col2:
93
  st.subheader("Yearly Kiln Made")
94
  st.dataframe(yearly_summary)
95
+ # Dropdown to select the location
96
+
97
+ # Define historical data for Lucknow
98
+ years_lucknow = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]
99
+ brick_kilns_total_lucknow = [117, 314, 376, 396, 408, 432, 433, 454, 461, 466, 470, 477, 478]
100
+ brick_kilns_fcb_lucknow = [52, 127, 159, 171, 178, 191, 192, 206, 208, 209, 209, 209, 209]
101
+ brick_kilns_zigzag_lucknow = [65, 187, 217, 225, 230, 241, 241, 248, 253, 257, 261, 268, 269]
102
+
103
+ # Define historical data for Delhi
104
+ years_delhi = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]
105
+ brick_kilns_total_delhi = [188,502,649,701,719,751,770,770,775,783,794,795,796]
106
+ brick_kilns_fcb_delhi = [184,496,643,695,712,744,742,727,620,401,146,74,37]
107
+ brick_kilns_zigzag_delhi = [4,6,6,6,7,7,28,43,155,382,648,721,759]
108
+
109
+ # Select the dataset based on the location
110
+ if location == "Lucknow":
111
+ years = years_lucknow
112
+ brick_kilns_total = brick_kilns_total_lucknow
113
+ brick_kilns_fcb = brick_kilns_fcb_lucknow
114
+ brick_kilns_zigzag = brick_kilns_zigzag_lucknow
115
+ title = "Number of Brick Kilns Over Years in Lucknow"
116
+ else:
117
+ years = years_delhi
118
+ brick_kilns_total = brick_kilns_total_delhi
119
+ brick_kilns_fcb = brick_kilns_fcb_delhi
120
+ brick_kilns_zigzag = brick_kilns_zigzag_delhi
121
+ title = "Number of Brick Kilns Over Years in Delhi"
122
 
123
  # Creating the line plot for the number of brick kilns over the years
124
  fig_line = go.Figure()
 
129
 
130
  # Adding labels and title to the line chart
131
  fig_line.update_layout(
132
+ title=title,
133
  xaxis_title="Years",
134
  yaxis_title="Number of Brick Kilns",
135
+ yaxis=dict(tickmode='linear', tick0=0, dtick=100, showgrid=False),
136
  width=900
137
  )
138
 
139
  # Adding vertical line for the selected year
140
  fig_line.add_vline(x=year_selected, line_dash="dash", line_color="black", annotation_text=f"Year {year_selected}")
141
+
142
  # Displaying the line chart
143
+ st.plotly_chart(fig_line)
144
 
145
  # # Emission factors
146
  # emission_factor_pm25_fcb = 15000 * 6.8 # grams/day per FCB kiln