Close

Getting Air Quality Data to the Map & Reverse Geocoding

A project log for The Interactive Air Quality Map

A Physical Touch Reactive Map that shows the Air Quality of a location

ahmed-oyenugaAhmed Oyenuga 10/07/2022 at 00:160 Comments

The Air quality map currently gets all its air quality data from the DesignSpark Environmental Sensor Development Kit (ESDK), the data is being reported via MQTT to the Arduino WIFI 1010 on the map, the map reacts to data on a per area basis, and although I am yet to collect air quality data from most of the locations on the map, I did program random levels for the areas, except for "Ikorodu", which is the area I live in Lagos, so, the data shown for that area is live.

GPS

I hacked an A9G GPRS/GPS module into my air quality sensor which is what I'm currently using to record the GPS location from wherever I collect air quality data, I also created a little python program running on the raspberry pi on the sensor kit, the script combines the air quality data from the sensor with the GPS coordinates from the A9G module.

Reverse Geocoding

the A9G module gives me the GPS coordinates of the sensor, but the latitude and longitude doesn't really help the air quality map to understand where data is coming from, for that I needed to implement reverse geocoding, which is the process of converting latitude and longitude into readable address. I am using google's geocoding API for this purpose, all I have to do is send a GET request to the URL - https://maps.googleapis.com/maps/api/geocode/json?latlng=” Latitude here”,” Longitude here”&key=” API key here”, and then read and interpret the JSON response in my code.

from unittest import result
import requests

apiquery = "https://maps.googleapis.com/maps/api/geocode/json?latlng=latitude,longitude&key=API_key"

response = requests.get(apiquery)
data = response.json()

for i in data:
    if i == "results":
        try:                 
            print(data["results"][0]["address_components"][3]["long_name"])
            gotArea = data["results"][0]["address_components"][3]["long_name"]
    
        except:
            print("got index error")

    

The python script running on the sensor extracts the area/province name from the reverse geocoding response and appends the string to the air quality data, before sending it off to the

Discussions