Oct-16-2019, 03:28 PM
I'm finally done with collecting data from FAA website, now I want to add the data to a website using Folium. I'm using the following link for reference.
https://python-graph-gallery.com/312-add...olium-map/
When I run the script, its only adding the last airport, and I think the problem is because its not adding. When I run my code, I'm getting this below. If you notice, I'm showing 0 for everything.
I ran the code from the example above, and I'm getting this below, and its showing all the locations.
This is my script. I'm reading a CSV file which contains the name, latitude and longitude of the airports.
https://python-graph-gallery.com/312-add...olium-map/
When I run the script, its only adding the last airport, and I think the problem is because its not adding. When I run my code, I'm getting this below. If you notice, I'm showing 0 for everything.
Quote: lat lon name color metar
0 28.5455 -81.332901 Orlando Executive Airport Blue KORL 161453Z 23014KT 10SM FEW022 FEW029 29/22 ...
lat lon name color metar
0 66.91390228 -151.529007 Bettles Airport Green PABT 161453Z 01006KT 10SM CLR M15/M17 A2946 RM...
lat lon name color metar
0 65.99279785 -153.7039948 Indian Mountain LRRS Airport Green PAIM 161455Z 08014KT 040V140 10SM SCT150 BKN18...
lat lon name color metar
0 59.75439835 -154.9109955 Iliamna Airport Blue PAIL 161453Z 36004KT 10SM BKN022 OVC055 M01/M0...
lat lon name color metar
0 59.01139831542969 -161.82000732421875 Platinum Airport Blue PAPM 161456Z AUTO 11015KT 10SM -RA BKN020 BKN0...
lat lon name color metar
0 44.451599 -83.394096 Oscoda Wurtsmith Airport Blue KOSC 161515Z AUTO 26009KT 10SM OVC017 11/08 A2...
lat lon name color metar
0 38.55390167 -121.2979965 Sacramento Mather Airport Green KMHR 161455Z 11003KT 10SM SKC 08/04 A2999
lat lon name color metar
0 35.2804985046 -116.629997253 Bicycle Lake Army Air Field Green KBYS 161458Z AUTO 00000KT 8SM CLR 11/M11 A3006...
lat lon name color metar
0 34.2961998 -116.1620026 Twentynine Palms (Self) Airport Green KNXP 161456Z AUTO 32006KT 10SM CLR 16/M02 A301...
lat lon ... color metar
0 39.1754 -76.668297 ... Red KBWI 161517Z 14007G15KT 10SM -RA FEW009 SCT023...
[1 rows x 5 columns]
I ran the code from the example above, and I'm getting this below, and its showing all the locations.
Quote: lat lon name
0 -58.00 -34.00 Buenos Aires
1 2.00 49.00 Paris
2 145.00 -38.00 melbourne
3 30.32 59.93 St Petersbourg
4 -4.03 5.33 Abidjan
5 -73.57 45.52 Montreal
6 36.82 -1.29 Nairobi
7 -38.50 -12.97 Salvador
This is my script. I'm reading a CSV file which contains the name, latitude and longitude of the airports.
for row in csvread: icao = row[0] name = row[1] latitude = row[2] longitude = row[3] metar_link = 'https://www.aviationweather.gov/metar/data?ids=' + icao + '&format=decoded&date=&hours=0' page = requests.get(metar_link) soup = bs(page.content, 'html.parser') if soup.select_one('td:contains("Text:") + td').text == 'No data found' or not 'SM' in ( soup.select_one('td:contains("Text:") + td').text): continue metar = soup.select_one('td:contains("Text:") + td').text metar_data = func.fraction(metar) visibility = float(func.convert_to_float(metar_data)) ceiling = func.convert_ceiling(metar) flight_conditions = func.flight_conditions(ceiling, visibility) color = func.colorize(flight_conditions) data = pd.DataFrame({ 'lat': [latitude], 'lon': [longitude], 'name': [name], 'color': [color], 'metar': [metar] }) print(data) metar_map = folium.Map(location=[50.4512, -104.6166], tiles='cartodbpositron', zoom_start=4) for i in range(0, len(data)): folium.CircleMarker(location=[data.iloc[i]['lat'], data.iloc[i]['lon']], radius=5, color=data.iloc[i]['color'], fill=True, fill_color=data.iloc[i]['color'], tooltip=([data.iloc[i]['name']]+[data.iloc[i]['metar']])).add_to(metar_map) metar_map.save('metars_map.html')