├── file1 ├── README.md └── synthetic_noise_data.csv /file1: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import geopandas as gpd 3 | import folium 4 | from shapely.geometry import Point 5 | from sklearn.neighbors import KNeighborsRegressor 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | 9 | # ----------------------------- 10 | # Step 1: Load Noise Data 11 | # ----------------------------- 12 | # Sample CSV format: latitude,longitude,noise_level_dB 13 | noise_df = pd.read_csv("noise_data.csv") # replace with your file 14 | 15 | # Create GeoDataFrame 16 | geometry = [Point(xy) for xy in zip(noise_df['longitude'], noise_df['latitude'])] 17 | gdf = gpd.GeoDataFrame(noise_df, geometry=geometry) 18 | gdf.set_crs(epsg=4326, inplace=True) # WGS 84 19 | 20 | # ----------------------------- 21 | # Step 2: Display Basic Map 22 | # ----------------------------- 23 | m = folium.Map(location=[gdf.latitude.mean(), gdf.longitude.mean()], zoom_start=13) 24 | for _, row in gdf.iterrows(): 25 | folium.CircleMarker( 26 | location=(row.latitude, row.longitude), 27 | radius=6, 28 | popup=f"Noise: {row.noise_level_dB} dB", 29 | color="red" if row.noise_level_dB > 70 else "green", 30 | fill=True 31 | ).add_to(m) 32 | 33 | m.save("noise_pollution_map.html") 34 | print("Basic noise pollution map saved as 'noise_pollution_map.html'") 35 | 36 | # ----------------------------- 37 | # Step 3: Interpolation (KNN) for Mapping Noise Surface 38 | # ----------------------------- 39 | # Create grid for predictions 40 | minx, miny, maxx, maxy = gdf.total_bounds 41 | xx, yy = np.meshgrid(np.linspace(minx, maxx, 100), np.linspace(miny, maxy, 100)) 42 | grid_points = pd.DataFrame({'longitude': xx.ravel(), 'latitude': yy.ravel()}) 43 | 44 | # Fit KNN model 45 | X = gdf[['longitude', 'latitude']] 46 | y = gdf['noise_level_dB'] 47 | knn = KNeighborsRegressor(n_neighbors=5) 48 | knn.fit(X, y) 49 | 50 | # Predict on grid 51 | grid_points['noise_level_dB'] = knn.predict(grid_points[['longitude', 'latitude']]) 52 | 53 | # ----------------------------- 54 | # Step 4: Plot Heatmap 55 | # ----------------------------- 56 | plt.figure(figsize=(10, 8)) 57 | plt.tricontourf(grid_points['longitude'], grid_points['latitude'], grid_points['noise_level_dB'], levels=15, cmap='coolwarm') 58 | plt.colorbar(label='Noise Level (dB)') 59 | plt.scatter(gdf['longitude'], gdf['latitude'], c='black', s=10, label='Sensor Locations') 60 | plt.title('Noise Pollution Interpolation Map') 61 | plt.xlabel('Longitude') 62 | plt.ylabel('Latitude') 63 | plt.legend() 64 | plt.savefig('noise_pollution_heatmap.png', dpi=300) 65 | plt.show() 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📊 Noise Pollution Mapping in Urban Areas 2 | 3 | This project provides a complete workflow for mapping, visualizing, and analyzing noise pollution levels in urban areas using geospatial and machine learning techniques. It utilizes geo-tagged noise data to generate interactive maps and heatmaps that aid in understanding spatial noise variability, which is crucial for urban planning, public health, and environmental management. 4 | 5 | --- 6 | 7 | ## 🚀 Features 8 | 9 | - 📍 Mapping of noise pollution levels using GPS-tagged sensor data. 10 | - 🗺️ Interactive map with noise level markers using `folium`. 11 | - 🌡️ Interpolated heatmap of noise distribution using K-Nearest Neighbors (KNN). 12 | - 📈 Visual analysis of urban noise trends with `matplotlib`. 13 | - 🧠 Machine learning-based spatial prediction of unmonitored areas. 14 | 15 | --- 16 | 17 | ## 📂 Project Structure 18 | 19 | noise-pollution-mapping/ 20 | │ 21 | ├── noise_pollution_mapping.py # Main script for mapping and interpolation 22 | ├── synthetic_noise_data.csv # Sample synthetic dataset (GPS + dB readings) 23 | ├── noise_pollution_map.html # Interactive folium map output 24 | ├── noise_pollution_heatmap.png # Interpolated heatmap output 25 | └── README.md # Project documentation 26 | 27 | 28 | --- 29 | 30 | ## 📦 Requirements 31 | 32 | Install the necessary Python packages: 33 | 34 | ```bash 35 | pip install pandas geopandas folium matplotlib scikit-learn shapely 36 | 37 | 📥 Input Format 38 | 39 | The input CSV file must include the following columns: 40 | 41 | latitude,longitude,noise_level_dB 42 | 6.5244,3.3792,65 43 | 6.5278,3.3810,75 44 | ... 45 | 46 | 🛠️ How to Use 47 | 48 | Clone the repository or download the files. 49 | 50 | Replace noise_data.csv with your real-world data or use the provided synthetic_noise_data.csv. 51 | 52 | Run the main script: 53 | 54 | python noise_pollution_mapping.py 55 | 56 | View: 57 | 58 | noise_pollution_map.html for the interactive map. 59 | 60 | noise_pollution_heatmap.png for the static heatmap. 61 | 62 | 📊 Use Cases 63 | 64 | Environmental noise assessment 65 | 66 | Urban planning and zoning 67 | 68 | Health impact studies 69 | 70 | Smart city and IoT sensor deployment 71 | 72 | 👤 Author 73 | 74 | Ugochukwu Charles Akajiaku 75 | GitHub Profile 76 | LinkedIn 77 | 📜 License 78 | 79 | This project is licensed under the MIT License - feel free to use and modify. 80 | 81 | 82 | --- 83 | 84 | Would you like me to save this `README.md` file alongside the dataset as well? 85 | -------------------------------------------------------------------------------- /synthetic_noise_data.csv: -------------------------------------------------------------------------------- 1 | latitude,longitude,noise_level_dB 2 | 6.518727005942368,3.3984792313882277,70.87047068238171 3 | 6.547535715320496,3.388756641168056,67.00992649534132 4 | 6.53659969709057,3.3969749470782094,70.91760776535503 5 | 6.529932924209851,3.3947413675213824,50.124310853991076 6 | 6.507800932022122,3.3798949989405545,67.80328112162488 7 | 6.50779972601681,3.396093711751156,73.57112571511746 8 | 6.50290418060841,3.354424625102596,84.77894044741517 9 | 6.543308807288747,3.3597991431209575,64.81729781726352 10 | 6.53005575058716,3.352261364445527,61.91506397106812 11 | 6.535403628889802,3.3662665165381633,64.98242956415463 12 | 6.50102922471479,3.369433864484474,79.15402117702074 13 | 6.548495492608099,3.3635674515886946,73.28751109659684 14 | 6.541622132040021,3.3914368754575963,64.70239796232961 15 | 6.510616955533914,3.3678376663346796,75.13267433113356 16 | 6.509091248360355,3.364046725484369,70.9707754934804 17 | 6.509170225492672,3.3771348041579126,79.68644990532889 18 | 6.515212112147977,3.357046211248738,62.979469061226474 19 | 6.526237821581612,3.3901098490377017,66.72337853402232 20 | 6.521597250932106,3.3537275321839886,66.07891846867842 21 | 6.514561457009902,3.3993443468300257,55.364850518678814 22 | 6.530592644736119,3.388612238464833,72.96120277064576 23 | 6.5069746930326025,3.3599357840767086,72.6105527217989 24 | 6.514607232426761,3.3502761058561803,70.05113456642461 25 | 6.518318092164685,3.3907730714227418,67.65412866624852 26 | 6.522803499210852,3.3853428671923806,55.84629257949586 27 | 6.539258798069651,3.3864503584020493,65.79354677234642 28 | 6.509983689107918,3.388563517334297,66.57285483473231 29 | 6.525711721920681,3.3537022325867047,61.97722730778381 30 | 6.529620728443102,3.3679232864272137,68.3871428833399 31 | 6.502322520636,3.3557934529762568,74.04050856814538 32 | 6.530377242595072,3.3931551712937797,88.8618590121053 33 | 6.5085262061843645,3.381164906341378,71.74577812831839 34 | 6.503252579649264,3.3665449012426323,72.57550390722764 35 | 6.547444276862667,3.353177917514301,69.25554084233833 36 | 6.548281601653728,3.3655491160857833,50.812287847009586 37 | 6.540419867405823,3.3662591661013375,69.73486124550783 38 | 6.515230688458669,3.3864803089169033,70.60230209941027 39 | 6.504883605700319,3.3818778735677606,94.63242112485287 40 | 6.534211651325608,3.394360637128816,68.07639035218878 41 | 6.52200762468698,3.3736107462580973,73.01547342333612 42 | 6.506101911742239,3.3559797122969153,69.65288230294756 43 | 6.524758845505564,3.3856622393611495,58.31321962380468 44 | 6.501719426055761,3.3880392524308447,81.4282281451502 45 | 6.545466020103939,3.3780638598784747,77.51933032686775 46 | 6.512938999080001,3.388548358997728,77.91031947043047 47 | 6.533126114217699,3.3746897798182194,60.906125452052606 48 | 6.5155855538044705,3.3761366414691,84.02794310936099 49 | 6.52600340105889,3.3713770509179275,55.98148937207719 50 | 6.527335513967164,3.351270956337205,75.8685709380027 51 | 6.509242722776277,3.3553945713496653,91.90455625809979 52 | --------------------------------------------------------------------------------