CHATGPT AI
volcano
_data.csv
§ Output
> stdout : [' Volcano Name Country Region Elevation (m) \\\n', '0 Baker US Alaska, USA 3053.0 \n', '1 Chiginagak US Alaska, USA 2236.0 \n', '2 Fourpeaked ... Stratovolcano D4 58.424700 -154.814800 \n', '2 Stratovolcano D3 59.848100 -153.983200 \n', '3 Caldera D3 59.320400 -153.434500 \n', '4 Stratovolcano D2 59.937900 -152.939000 \n', 'Volcano data saved!\n']
§ Code
# Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests
import time
# Import API key
from api_keys import api_key
# Incorporated citipy to determine city based on latitude and longitude
from citipy import citipy
# Output File (CSV)
output_data_file = "output_data/cities.csv"
# Range of latitudes and longitudes
lat_range = (-90, 90)
lng_range = (-180, 180)
# List for holding lat_lngs and cities
lat_lngs = []
cities = []
# Create a set of random lat and lng combinations
lats = np.random.uniform(low=-90.000, high=90.000, size=1500)
lngs = np.random.uniform(low=-180.000, high=180.000, size=1500)
lat_lngs = zip(lats, lngs)
# Identify nearest city for each lat, lng combination
for lat_lng in lat_lngs:
city = citipy.nearest_city(lat_lng[0], lat_lng[1]).city_name
# If the city is unique, then add it to a our cities list if city not in cities: cities
§ Output
> stdout : [' Volcano Name Country Region Elevation (m) \\\n', '0 Baker US Alaska, USA 3053.0 \n', '1 Chiginagak US Alaska, USA 2236.0 \n', '2 Fourpeaked ... Stratovolcano D4 58.424700 -154.814800 \n', '2 Stratovolcano D3 59.848100 -153.983200 \n', '3 Caldera D3 59.320400 -153.434500 \n', '4 Stratovolcano D2 59.937900 -152.939000 \n', 'Volcano data saved!\n']
§ Code
# Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests
import time
# Import API key
from api_keys import api_key
# Incorporated citipy to determine city based on latitude and longitude
from citipy import citipy
# Output File (CSV)
output_data_file = "output_data/cities.csv"
# Range of latitudes and longitudes
lat_range = (-90, 90)
lng_range = (-180, 180)
# List for holding lat_lngs and cities
lat_lngs = []
cities = []
# Create a set of random lat and lng combinations
lats = np.random.uniform(low=-90.000, high=90.000, size=1500)
lngs = np.random.uniform(low=-180.000, high=180.000, size=1500)
lat_lngs = zip(lats, lngs)
# Identify nearest city for each lat, lng combination
for lat_lng in lat_lngs:
city = citipy.nearest_city(lat_lng[0], lat_lng[1]).city_name
# If the city is unique, then add it to a our cities list if city not in cities: cities
_data.csv
§ Output
> stdout : [' Volcano Name Country Region Elevation (m) \\\n', '0 Baker US Alaska, USA 3053.0 \n', '1 Chiginagak US Alaska, USA 2236.0 \n', '2 Fourpeaked ... Stratovolcano D4 58.424700 -154.814800 \n', '2 Stratovolcano D3 59.848100 -153.983200 \n', '3 Caldera D3 59.320400 -153.434500 \n', '4 Stratovolcano D2 59.937900 -152.939000 \n', 'Volcano data saved!\n']
§ Code
# Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests
import time
# Import API key
from api_keys import api_key
# Incorporated citipy to determine city based on latitude and longitude
from citipy import citipy
# Output File (CSV)
output_data_file = "output_data/cities.csv"
# Range of latitudes and longitudes
lat_range = (-90, 90)
lng_range = (-180, 180)
# List for holding lat_lngs and cities
lat_lngs = []
cities = []
# Create a set of random lat and lng combinations
lats = np.random.uniform(low=-90.000, high=90.000, size=1500)
lngs = np.random.uniform(low=-180.000, high=180.000, size=1500)
lat_lngs = zip(lats, lngs)
# Identify nearest city for each lat, lng combination
for lat_lng in lat_lngs:
city = citipy.nearest_city(lat_lng[0], lat_lng[1]).city_name
# If the city is unique, then add it to a our cities list if city not in cities: cities
0 Comments & Tags
0 Compartilhamentos
1 Visualizações