RISHABH MONDAL commited on
Commit
5bdc506
·
verified ·
1 Parent(s): 42fcaa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -22
app.py CHANGED
@@ -4,27 +4,27 @@ 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
- st.markdown("<h2 style='text-align: center;'>Brick Kiln Location and Conversion Visualization</h2>", unsafe_allow_html=True)
9
 
10
  # Dropdown to select the location
11
  location = st.selectbox("Select Location", ["Lucknow", "Delhi", "Ahmedabad"])
12
 
13
  # Determine the file path based on selection
14
  if location == "Lucknow":
15
- file = "brick_kiln_lucknow_v1.csv"
16
  center_lat, center_lon = 26.8467, 80.9462
17
  elif location == "Delhi":
18
- file = "brick_kiln_delhi_v1.csv"
19
  center_lat, center_lon = 28.7041, 77.1025
20
  else: # Ahmedabad
21
- file = "brick_kiln_ahmedabad_v2.csv" # Replace with the actual path
22
  center_lat, center_lon = 23.0225, 72.5714
23
 
24
 
25
  data = pd.read_csv(file)
26
 
27
  # Streamlit app title
 
28
 
29
  # Slider to select the year
30
  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)
@@ -45,6 +45,8 @@ def get_status(row, year_selected):
45
  else:
46
  return "zigzag"
47
 
 
 
48
  # Function to classify each kiln based on the selected year
49
  def classify_kiln(row, year_selected):
50
  if row["Year made"] > year_selected:
@@ -88,22 +90,53 @@ else:
88
 
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- # Plotting the filtered data points on a map, with different colors for statuses
93
- fig_filtered = px.scatter_mapbox(
94
- data,
95
- lat="Lat",
96
- lon="Lon",
97
- color="Status",
98
- color_discrete_map={"fcbk": "blue", "converted": "green", "zigzag": "red"}, # Set colors for fcbk, converted, and zigzag kilns
99
- mapbox_style="carto-positron",
100
- hover_name="Type",
101
- zoom=8.5,
102
- center={"lat": center_lat, "lon": center_lon},
103
- title=f"Brick Kiln Locations and Status up to Year {year_selected}",
104
- height=600,
105
- width=600
106
- )
107
 
108
  # # Display the map in Streamlit
109
  # st.plotly_chart(fig_filtered)
@@ -136,8 +169,8 @@ brick_kilns_zigzag_delhi = [4,6,6,6,7,7,28,43,155,382,648,721,759]
136
 
137
  #define for Ahmedabad
138
  years_ahmedabad = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]
139
- brick_kilns_total_ahmedabad = [74,92,115,136,140,155,155,166,156,164,165,169,172]
140
- brick_kilns_fcb_ahmedabad = [74,92,115,136,140,155,155,166,156,164,165,168,172]
141
  brick_kilns_zigzag_ahmedabad = [0,0,0,0,0,0,0,0,0,0,0,1,0]
142
 
143
  # Select the dataset based on the location
 
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", "Ahmedabad"])
11
 
12
  # Determine the file path based on selection
13
  if location == "Lucknow":
14
+ file = "/home/rishabh.mondal/Brick-Kilns-project/albk_rishabh/albk_v2/YOLO_LOCALIZATION/Compliance-app/brick_kiln_lucknow_v1.csv"
15
  center_lat, center_lon = 26.8467, 80.9462
16
  elif location == "Delhi":
17
+ file = "/home/rishabh.mondal/Brick-Kilns-project/albk_rishabh/albk_v2/YOLO_LOCALIZATION/Compliance-app/brick_kiln_delhi_v1.csv"
18
  center_lat, center_lon = 28.7041, 77.1025
19
  else: # Ahmedabad
20
+ file = "/home/rishabh.mondal/Brick-Kilns-project/albk_rishabh/albk_v2/YOLO_LOCALIZATION/Compliance-app/brick_kiln_ahmedabad_v2.csv" # Replace with the actual path
21
  center_lat, center_lon = 23.0225, 72.5714
22
 
23
 
24
  data = pd.read_csv(file)
25
 
26
  # Streamlit app title
27
+ st.markdown("<h2 style='text-align: center;'>Brick Kiln Location and Conversion Visualization</h2>", unsafe_allow_html=True)
28
 
29
  # Slider to select the year
30
  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)
 
45
  else:
46
  return "zigzag"
47
 
48
+
49
+
50
  # Function to classify each kiln based on the selected year
51
  def classify_kiln(row, year_selected):
52
  if row["Year made"] > year_selected:
 
90
 
91
 
92
 
93
+ if location == "Lucknow":
94
+ fig_filtered = px.scatter_mapbox(
95
+ data,
96
+ lat="Lat",
97
+ lon="Lon",
98
+ color="Status",
99
+ color_discrete_map={"fcbk": "blue", "converted": "green", "zigzag": "red"}, # Set colors for fcbk, converted, and zigzag kilns
100
+ mapbox_style="carto-positron",
101
+ hover_name="Type",
102
+ zoom=8.5,
103
+ center={"lat": center_lat, "lon": center_lon},
104
+ title=f"Brick Kiln Locations and Status up to Year {year_selected}",
105
+ height=600,
106
+ width=600
107
+ )
108
+ elif location == "Delhi":
109
+ fig_filtered = px.scatter_mapbox(
110
+ data,
111
+ lat="Lat",
112
+ lon="Lon",
113
+ color="Status1",
114
+ color_discrete_map={"FCBK": "blue", "converted": "green", "Zigzag": "red"}, # Set colors for fcbk, converted, and zigzag kilns
115
+ mapbox_style="carto-positron",
116
+ hover_name="Type",
117
+ zoom=8.5,
118
+ center={"lat": center_lat, "lon": center_lon},
119
+ title=f"Brick Kiln Locations and Status up to Year {year_selected}",
120
+ height=600,
121
+ width=600
122
+ )
123
+ else:
124
+ fig_filtered = px.scatter_mapbox(
125
+ data,
126
+ lat="Lat",
127
+ lon="Lon",
128
+ color="Status",
129
+ color_discrete_map={"fcbk": "blue", "zigzag": "red"}, # Set colors for fcbk, converted, and zigzag kilns
130
+ mapbox_style="carto-positron",
131
+ hover_name="Type",
132
+ zoom=8.5,
133
+ center={"lat": center_lat, "lon": center_lon},
134
+ title=f"Brick Kiln Locations and Status up to Year {year_selected}",
135
+ height=600,
136
+ width=600
137
+ )
138
+
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  # # Display the map in Streamlit
142
  # st.plotly_chart(fig_filtered)
 
169
 
170
  #define for Ahmedabad
171
  years_ahmedabad = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]
172
+ brick_kilns_total_ahmedabad = [74,92,115,136,140,155,155,156,156,164,165,169,172]
173
+ brick_kilns_fcb_ahmedabad = [74,92,115,136,140,155,155,156,156,164,165,168,172]
174
  brick_kilns_zigzag_ahmedabad = [0,0,0,0,0,0,0,0,0,0,0,1,0]
175
 
176
  # Select the dataset based on the location