import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import folium from branca.colormap import linear from branca.colormap import LinearColormap import numpy as np # Load the data from the file #file_path = "./1352-1433UTC_Aug1_2024_CH4_lat_lon.txt" file_path = "./930-1400UTC_Jun26_2024_CH4_lat_lon.txt" figure_path = "./" data = pd.read_csv(file_path, delim_whitespace=True, header=0) # Filter out invalid methane concentration values data = data[data['CH4LicormatchIphonePPB'] > 0] # plot figure m = folium.Map(location=[np.mean(data['lat']), np.mean(data['lon'])], zoom_start=15, tiles=None) # Add a tile layer (try different ones if 'OpenStreetMap' doesn't work) folium.TileLayer('OpenStreetMap',name='Street View').add_to(m) folium.TileLayer('Esri.WorldImagery',name='Satellite View').add_to(m) vmin = 2000 vmax = 2600 color_scale = LinearColormap(['blue', 'cyan', 'yellow', 'red'], vmin=vmin, vmax=vmax) # Adding a color bar color_scale.caption = 'Methane Concentration (ppb)' color_scale.add_to(m) # Add markers for lat, lon, ch4 in zip(data['lat'], data['lon'], data['CH4LicormatchIphonePPB']): if ch4 > 0: # Assuming negative values are invalid folium.CircleMarker( location=[lat, lon], radius=0.2, color=color_scale(ch4), fill=True, fill_color=color_scale(ch4), fill_opacity=0.7, popup=f'{ch4:.2f} ppb' ).add_to(m) folium.LayerControl().add_to(m) # Save and show the map m.save(figure_path+'mathane_map_Jun26_2024.html')