Rajkhanke007 commited on
Commit
8d88cd5
·
verified ·
1 Parent(s): 8a72206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -72
app.py CHANGED
@@ -164,78 +164,6 @@ def crop_analysis():
164
  return render_template('index.html', map_html=map_html, selected_map="District Crop Analysis")
165
 
166
 
167
- @app.route('/combined_analysis')
168
- def combined_analysis():
169
- global df # Declare df as global
170
-
171
- # Sample a fraction of the dataframe for performance
172
- df_sampled = df.sample(frac=0.005, random_state=42)
173
-
174
- # Create the map centered over India with an appropriate zoom level
175
- m = folium.Map(location=[20.5937, 78.9629], zoom_start=5)
176
-
177
- # Prepare heatmap data for area
178
- area_heat_data = [
179
- [row['Latitude'], row['Longitude'], row['Area']]
180
- for _, row in df_sampled.iterrows()
181
- ]
182
-
183
- # Add the heatmap for area (blue to red: low to high)
184
- HeatMap(
185
- data=area_heat_data,
186
- min_opacity=0.3,
187
- max_opacity=0.8,
188
- radius=15,
189
- blur=10,
190
- gradient={0.0: 'blue', 0.5: 'lightblue', 1.0: 'red'}
191
- ).add_to(m)
192
-
193
- # Prepare heatmap data for production
194
- production_heat_data = [
195
- [row['Latitude'], row['Longitude'], row['Production']]
196
- for _, row in df_sampled.iterrows()
197
- ]
198
-
199
- # Add the heatmap for production (green to red: low to high production)
200
- HeatMap(
201
- data=production_heat_data,
202
- min_opacity=0.3,
203
- max_opacity=0.8,
204
- radius=15,
205
- blur=10,
206
- gradient={0.0: 'green', 0.5: 'yellow', 1.0: 'red'}
207
- ).add_to(m)
208
-
209
- # Scatter plot for different seasons with distinct colors
210
- season_colors = {
211
- 'Kharif': 'purple',
212
- 'Rabi': 'orange',
213
- 'Rabi': 'cyan',
214
- 'Winter':'Yellow',
215
- 'Summer':'Green',
216
- 'Whole Year':'Red'
217
- }
218
-
219
- for _, row in df_sampled.iterrows():
220
- season = row['Season']
221
- color = season_colors.get(season, 'gray') # Default to gray if the season is not recognized
222
- folium.CircleMarker(
223
- location=[row['Latitude'], row['Longitude']],
224
- radius=5,
225
- color=color,
226
- fill=True,
227
- fill_opacity=0.7,
228
- tooltip=(f"District: {row['District']}<br>"
229
- f"Season: {row['Season']}<br>"
230
- f"Area: {row['Area']}<br>"
231
- f"Production: {row['Production']}")
232
- ).add_to(m)
233
-
234
- # Convert the map to HTML format
235
- map_html = m._repr_html_()
236
-
237
- # Render the map in the template
238
- return render_template('index.html', map_html=map_html, selected_map="Combined Area & Production Heatmaps")
239
 
240
  if __name__ == '__main__':
241
  app.run(port=7860,host='0.0.0.0')
 
164
  return render_template('index.html', map_html=map_html, selected_map="District Crop Analysis")
165
 
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  if __name__ == '__main__':
169
  app.run(port=7860,host='0.0.0.0')