Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dennis-nichols/clean-air-compass-mapping-api
An API to do spatial interpolation of Purple Air network sensor data and create polygons for display on web maps.
https://github.com/dennis-nichols/clean-air-compass-mapping-api
fastapi geopandas numpy pandas python scikit
Last synced: 15 days ago
JSON representation
An API to do spatial interpolation of Purple Air network sensor data and create polygons for display on web maps.
- Host: GitHub
- URL: https://github.com/dennis-nichols/clean-air-compass-mapping-api
- Owner: dennis-nichols
- Created: 2023-02-19T07:20:51.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-24T20:14:49.000Z (over 1 year ago)
- Last Synced: 2024-01-25T22:17:22.361Z (12 months ago)
- Topics: fastapi, geopandas, numpy, pandas, python, scikit
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clean Air Compass - Mapping API
An API to handle location requests from the Clean Air Compass frontend and return an interpolated map of air pollution (PM 2.5) in the form of a list of georeferenced polygons.
## Details
The API conducts the following steps:
- Parses the location request to see if it is for a city or a US postal code
- Makes a request to the [LocationIQ API](https://locationiq.com/) and get back a bounding box of lat / lon coordinates
- Makes a request to the [Purple Air API](https://www2.purpleair.com/) to get back the list of sensors within the bounding box as well as their associated air pollution data
- Creates a spatial data frame from the sensor API response object using `geopandas`
- Creates a grid of polygons based on the spatial extent of the collection of sensor points and estimates the PM 2.5 pollution at each grid cell using the K-nearest neigbors (KNN) regressor method and the `scikit-learn` library.
- Returns the grid of polygons to the frontend as a GeoJSON object## How to run
1. Clone the repo
2. Install all dependencies by running `pip install -r requirements.txt` in the console
3. Create your own environment file where you set the values for your own Location IQ API key (`LOC_IQ_KEY`) and Purple Air API key (`API_KEY`) respectively.
4. Run the API server locally using `uvicorn main:app --reload`