Currently when accessing the data, I receive a huge array of data which doesn’t really hold any meaning to me. I would like to filter the data such that only sensors that are near me are returned. How would I go about doing this?
Looking at the map, the distribution of the sensors aren’t necessarily even nor contiguous. If I wanted to limit the number of sensor data I receive, such as the 5 nearest sensors to my location, how would I do that?
Hello @dddictionary,
To answer your question. you can filter down your result by using a multiple-sensor request. Loading... . If the link doesn’t work see the “Sensors - Get Sensors Data” section at “api.purpleair.com”
Use the “fields” field to get the information you need. Then add on latitude and longitude to reduce the number of sensors returned. Those fields are the “nwlng”, “nwlat”, “selng”, and “selat”.
I am not sure what language or tools you are using. Full disclosure the python tools I am about to recommend are ones that I have written and published to Github and PyPi. The tools are not perfect, but if you have issues feel free to reach out to me.
Python Purpleair API Wrapper - GitHub - carlkid1499/purpleair_api: Find this package on pypi: https://pypi.org/project/purpleair-api/#history You can grab your own sensor here: https://www2.purpleair.com/
Python Purpleair API Data Loggers - GitHub - carlkid1499/purpleair_data_logger: A logger that will query purple air sensor(s) for data. That data can then be stored in a PostGreSQL database, CSV files, or SQLite3 databse. Find this package on pypi: https://pypi.org/project/purpleair-data-logger/#history You can grab your own sensor here: https://www2.purpleair.com/
Hope this helps!
Hello, @carlkidcrypto-paa,
Thank you for your reply. I completely overlooked the fact that there were fields that reduced the number of sensors that are returned. (most likely because the api endpoints for this feature is the same as the default endpont). Nonetheless, I have managed to the data that I need through limiting these sensors. As for the zip code, I found a kaggle dataset that contains zip codes and their latitude and longitude. I will be using those to limit sensor data within that geolocation.
Best,
dddictionary
1 Like