Update app.py
Browse files
app.py
CHANGED
|
@@ -105,26 +105,24 @@ def create_map_figure(df, title="Carte des Foyers"):
|
|
| 105 |
fig.update_layout(mapbox_style="open-street-map")
|
| 106 |
return fig
|
| 107 |
|
| 108 |
-
|
| 109 |
-
size_col_name = None
|
| 110 |
-
if 'totalAnimalsAffected' in df.columns:
|
| 111 |
-
size_col_name = 'totalAnimalsAffected'
|
| 112 |
-
elif 'cases' in df.columns:
|
| 113 |
-
size_col_name = 'cases'
|
| 114 |
-
elif 'deaths' in df.columns:
|
| 115 |
-
size_col_name = 'deaths'
|
| 116 |
-
|
| 117 |
-
df_plot = df.copy() # Travailler sur une copie pour ne pas modifier l'original
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
if size_col_name:
|
| 120 |
df_plot['size_for_plotting'] = pd.to_numeric(df_plot[size_col_name], errors='coerce').fillna(1)
|
| 121 |
fig = px.scatter_mapbox(df_plot, lat="latitude", lon="longitude", color="diseaseName",
|
| 122 |
size='size_for_plotting', size_max=30,
|
| 123 |
-
hover_name=
|
| 124 |
else:
|
| 125 |
-
# Si aucune colonne de taille n'est trouvée, dessiner des points de taille égale
|
| 126 |
fig = px.scatter_mapbox(df_plot, lat="latitude", lon="longitude", color="diseaseName",
|
| 127 |
-
hover_name=
|
| 128 |
|
| 129 |
fig.update_layout(mapbox_style="open-street-map", margin={"r":0,"t":40,"l":0,"b":0})
|
| 130 |
return fig
|
|
@@ -142,7 +140,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="WAHIS Scraper") as demo:
|
|
| 142 |
gr.Markdown("# 🤖 Scraper pour WAHIS (WOAH) - Version Robuste")
|
| 143 |
run_button = gr.Button("🚀 Lancer l'extraction des données", variant="primary")
|
| 144 |
|
| 145 |
-
status_message = gr.Markdown("")
|
| 146 |
|
| 147 |
with gr.Accordion("Journal d'exécution", open=False):
|
| 148 |
status_textbox = gr.Textbox(lines=15, label="📜 Logs", interactive=False)
|
|
|
|
| 105 |
fig.update_layout(mapbox_style="open-street-map")
|
| 106 |
return fig
|
| 107 |
|
| 108 |
+
df_plot = df.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
size_col_name = None
|
| 111 |
+
if 'totalAnimalsAffected' in df_plot.columns: size_col_name = 'totalAnimalsAffected'
|
| 112 |
+
elif 'cases' in df_plot.columns: size_col_name = 'cases'
|
| 113 |
+
elif 'deaths' in df_plot.columns: size_col_name = 'deaths'
|
| 114 |
+
|
| 115 |
+
# CORRECTION : Utiliser 'locationName' qui est le bon nom de colonne
|
| 116 |
+
hover_name_col = 'locationName' if 'locationName' in df_plot.columns else None
|
| 117 |
+
|
| 118 |
if size_col_name:
|
| 119 |
df_plot['size_for_plotting'] = pd.to_numeric(df_plot[size_col_name], errors='coerce').fillna(1)
|
| 120 |
fig = px.scatter_mapbox(df_plot, lat="latitude", lon="longitude", color="diseaseName",
|
| 121 |
size='size_for_plotting', size_max=30,
|
| 122 |
+
hover_name=hover_name_col, title=title, zoom=1, height=600)
|
| 123 |
else:
|
|
|
|
| 124 |
fig = px.scatter_mapbox(df_plot, lat="latitude", lon="longitude", color="diseaseName",
|
| 125 |
+
hover_name=hover_name_col, title=title, zoom=1, height=600)
|
| 126 |
|
| 127 |
fig.update_layout(mapbox_style="open-street-map", margin={"r":0,"t":40,"l":0,"b":0})
|
| 128 |
return fig
|
|
|
|
| 140 |
gr.Markdown("# 🤖 Scraper pour WAHIS (WOAH) - Version Robuste")
|
| 141 |
run_button = gr.Button("🚀 Lancer l'extraction des données", variant="primary")
|
| 142 |
|
| 143 |
+
status_message = gr.Markdown("")
|
| 144 |
|
| 145 |
with gr.Accordion("Journal d'exécution", open=False):
|
| 146 |
status_textbox = gr.Textbox(lines=15, label="📜 Logs", interactive=False)
|