New to programming so forgive me if I say something erroneous. Im currently working on a small project which plots volcanoes onto a map using folium. The dataset im using can be found here: https://www.ngdc.noaa.gov/nndc/struts/form?t=102557&s=50&d=50 I have saved this as a CSV file to read into my program.
when I run my program, i am getting the following error:
...line 31, in <module>
folium.Marker(location=[lat, lon], popup=name, icon=folium.Icon(color=colour(elev), icon='cloud')).add_to(map)...
ValueError: Location values cannot contain NaNs, got:
[nan, nan]
Am i right in thinking this is because the program is not reading the [lat, lon] values as numbers on line 31? I was initially getting this error on line 16 also, but i have since changed [lat, lon] to [latmean, lonmean] which seems to have rectified the problem, although this suggests the program is reading the numbers in order to apply an average to them in the first place. Either way, im confused as to whats causing the problem. any help would be much appreciated!
my code is as follows:
import pandas as pd
import folium
df = pd.read_csv('data.csv')
latmean = df['Latitude'].mean()
lonmean = df['Longitude'].mean()
map = folium.Map(location=[latmean, lonmean], zoom_start=7, tiles='Stamen
Terrain')
def colour(elev):
if elev in range (0, 1000):
col = 'blue'
elif elev in range (1001, 1999):
col = 'green'
elif elev in range (2000, 2999):
col = 'orange'
else:
col = 'red'
return col
for lat, lon, name, elev in zip(df['Latitude'], df['Longitude'], df['Name'],
df['Elevation']):
folium.Marker(location=[lat, lon], popup=name, icon=folium.Icon(color=colour(elev), icon='cloud')).add_to(map)
print(map.save('test.html'))