Estos datos sobre terremotos son cortesía de USGS.
{query_address}
Escribe una dirección para ordenar los terremotos recientes por distancia.
# CrossCompute
target_folder = '/tmp'
query_address = 'David, Chiriquí'
from geopy.geocoders import GoogleV3
g = GoogleV3(api_key='AIzaSyDNqc0tWzXHx_wIp1w75-XTcCk4BSphB5w')
query_location = g.geocode(query_address, timeout=3)
query_point = query_location.point
query_point
import pandas as pd
table_url = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.csv'
table = pd.read_csv(table_url, parse_dates=['time'])
table.iloc[0]
table = table[['time', 'latitude', 'longitude', 'depth', 'mag', 'place']]
table.iloc[0]
from geopy.distance import vincenty as get_distance
def get_distance_in_km(x):
return pd.Series(get_distance(query_point, (x.latitude, x.longitude)).kilometers)
table['distanceInKm'] = table.apply(get_distance_in_km, axis=1)
table = table.sort_values(['distanceInKm'])
table[:3]
from datetime import datetime
now = datetime.utcnow()
def get_elapsed_time_in_negative_seconds(x):
return -1 * (now - x).seconds
geotable = table.copy()
geotable['fillReds'] = geotable['time'].apply(get_elapsed_time_in_negative_seconds)
geotable['radiusInPixelsRange3-27'] = geotable['mag']
geotable.iloc[0]
from os.path import join
table_path = join(target_folder, 'terremotos.csv')
table.to_csv(table_path, index=False)
print('terremotos_table_path = %s' % table_path)
geotable_path = join(target_folder, 'terremotos-mapa.csv')
geotable.to_csv(geotable_path, index=False)
print('terremotos_satellite_geotable_path = %s' % geotable_path)