Public Lab Research note


PurpleAir Sensor Data to Hosted Geospatial Data Layer

by seankmcginnis | June 03, 2021 14:26 03 Jun 14:26 | #26746 | #26746

seankmcginnis was awarded the Basic Barnstar by liz for their work in this research note.


A topic of conversation in the Organizing and Maps phone calls has been how to utilize data being collected by PurpleAir Real-time Air Quality Monitoring sensors as groups are starting to deploy them as part of their initiatives.

PurpleAir has a documented RESTful Application Programming Interface (API) that a user can get programmatic access to sensor data. I have written a sample Python Notebook that is scheduled to run every fifteen minutes which calls PurpleAir's API and loads the data into a hosted feature layer.

By putting it into the hosted feature layer, it becomes accessible in multiple service and file formats, including:

I have published the Python Notebook to GitHub for anyone interested in running the service or seeing how the data is being brought in from the PurpleAir API. Before running the script in your environment, there are a few dependencies:

  • Get an API key from PurpleAir
  • Modify the destination where the data is being written. I am using ArcGIS Online to store the feature layers, but your destination or file format may differ

Enhancement Opportunities

As we iterate through the sensors, we can check for certain threshold or average values. When we encounter a value of concern, the script can send a push notification or text message using something like Amazon Simple Notification Service


5 Comments

@eustatic just in case you didn't see this!

Reply to this comment...


This is absolutely wonderful, @seankmcginnis! Thanks for responding to needs brought up on the Open Calls by creating this custom code and sharing it!

I had a couple questions that I think will help me understand better how this works:

  • Would you be able to please say a little more about what a hosted feature layer is? Is it needed to obtain the Purple Air data in the different file formats you listed?
  • You wrote the code in the programming language Python--are there applications that you'd suggest someone could use to run this code, after they've downloaded it from your github page?

Thanks again, this is really helpful!

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


@liz awards a barnstar to seankmcginnis for their awesome contribution!

My first barnstar!!!!!!!!! Thanks @liz


Reply to this comment...


This is really, really cool @seankmcginnis

Reply to this comment...


Login to comment.