packages=["folium","pandas","matplotlib"]
import folium
import pandas as pd
from pyodide.http import open_url
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
# Define o URL base da API
url = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_day.csv'
# Define os parĂ¢metros da consulta
df = pd.read_csv(open_url(url))
#MAPA
m = folium.Map(location=[-15.77,-47.94],zoom_start=2,tiles='cartodbdark_matter')
grupo_terremotos = folium.map.FeatureGroup()
for lat, lon,magi in zip(df['latitude'],df['longitude'],df['mag']):
grupo_terremotos.add_child(
folium.CircleMarker([lat,lon],radius=magi,fill_color='red',
fill_opacity=0.5, color='red',popup=folium.Popup(f'Latitude:{lat}\n Longitude:{lon} \n Magnitude:{magi}'))
)
m.add_child(grupo_terremotos)
display(m,target="mapa",append=False)
#BLOCK1
fig = plt.figure(figsize=(2, 2))
fig.set_facecolor('#F8F9FA') # Define a cor de fundo como azul
text=fig.text(0.5, 0.5,str(len(df)), horizontalalignment='center',
verticalalignment='center',fontsize=24)
text.set_color('black')
text.set_path_effects([path_effects.Normal()])
display(fig,target="block1")
#BLOCK2
fig = plt.figure(figsize=(2, 2))
fig.set_facecolor('#F8F9FA')
text=fig.text(0.5, 0.5,str(df['mag'].max()), horizontalalignment='center',
verticalalignment='center',fontsize=24)
text.set_color('black')
text.set_path_effects([path_effects.Normal()])
display(fig,target="block2")
#BLOCK3
fig = plt.figure(figsize=(2, 2))
fig.set_facecolor('#F8F9FA')
indice_max = df['mag'].idxmax()
local_max = df.loc[indice_max, 'place']
text=fig.text(0.5, 0.5,str(local_max), horizontalalignment='center',
verticalalignment='center',fontsize=12,wrap=True)
text.set_color('black')
text.set_path_effects([path_effects.Normal()])
display(fig,target="block3")