Cal ToxTrack
A Web GIS for Mapping Pollution in California
This project uses a full stack approach (developed entirely from the backend database through the front-end interface) to map water pollution in California. The United States enforces a number of toxic substance and pollution control programs and laws, including the Emergency Planning and Community Right-to-Know Act and the Clean Air Act. While these programs have produced decades worth of valuable pollution datasets, the data is currently stored on a government website in a collection of CSV tables. This is overall inaccessible to the public, and inconvenient for analysis due to the static nature of tables. Therefore, this project focuses on developing a web application that lets the public easily explore large amounts of historic and current pollution data using an interactive web mapping environment with a time slider.
Cal ToxTrack interface
The user can (1) zoom to an address or pan a map to visualize locations and magnitudes of toxic chemical releases, (2) filter data by attributes including chemical name or facility, (3) temporally analyze the data with a dynamic time slider widget, and (4) visualize data with a bar chart. With Cal ToxTrack, users can utilize the map and spatiotemporal tools to visualize what chemicals have been released, at what magnitude, when and where; thus practicing their right-to-know.
Data
Environmental Protection Agency : The EPA provides pollution data from the Toxic Release Inventory and the Discharge Monitoring Report. About 40 CSV tables with pollution data needed to be downloaded and curated in R Studio.
Esri's API for JavaScript : This well made API is capitalized on by incorporating ready-to-use demographic data in the application. This significantly reduced the amount of data that needed to be pre-processed, allotting more time for the data that was not polished and the coding for the application itself.
Tools
Data is held and managed in a PostgreSQL database, with PostGIS as an extension to allow for geospatial functionality. Django with the GeoDjango extension was used to create an API for the pollution data. The interface was built with plain (Vanilla) JavaScript, while the Leaflet JavaScript library was used to implement mapping functionalities like zooming, geocoding, and geographic layer rendering. The Mapbox API was used to add multiple base layer tiles like Satellite Imagery and Street layers. The Google Chart API was used to incorporate a data summary bar chart.
Development Steps
(1) Data Preparation: Pollution data was downloaded from the TRI and DMR websites, which contain tables from as far back as 1987 and include information on facility location, facility name, pollutant name, and release quantity. R-Studio was used to complete data curating tasks which included filtering out NULL values and adding a year column to indicate when the chemical release occurred so the time slider tool could filter and render data by the user-selected year.
After pollution data was prepared, the Esri API data was incorporated by directly adding the URL of the ACS Total Population Boundaries feature layer into the project HTML file and specifying parameters that requested only boundaries from California and in GeoJSON format.
ACS Population Variables - Boundaries
(2) Back end web development: First, the PostgreSQL database was connected to GeoDjango by specifying credentials in a Python settings file. Then Python models were created for each set of pollution data, holding total releases and facility information. Then, these models were serialized to geoJSON and made available as an API by specifying URLs to the raw geoJSON data.
Python code that creates a URL to the API that the front end JavaScript code uses to retrieve a geoJSON with pollution data to be rendered in the map.
(3) Front end web development: After the map container was created, empty layers were added to the map and the JavaScript made a HTTP request for the pollution data created with Django. The data was added to the empty layers, then added to the map. Vanilla JavaScript is used to create filtering interfaces like a time slider and an attribute filter tool. These tools interact with the layer, to update and re-render them based on the user inputs in the time slider and the filter. Finally, the Google Chart API transforms the raw geoJSON into a data table that renders bar charts.
Future steps
Cal ToxTrack is a live application and will continue to be developed for the general public. Awareness of risk is the first step in keeping communities safe and extends chemical safety responsibility to those at risk by giving agency to the public. Cal ToxTrack was developed to be a tool that helps facilitate this awareness.
Future work involves encouraging the growth of a community of developers and users to expand the tools to be more sophisticated and analytical. Additional data from sources like Esri, environmental agencies, and the Census will be added to increase the analytical capability of the application.
About the Cal ToxTrack Application Developer
Megan is graduating from USC with a M.S. in GIS & Technology (`21) and a B.S. in Geology & Environmental Studies (`19). She is passionate about environmental sustainability and has worked on projects related to water pollution, drought mitigation, and site investigation and remediation. Post-graduation, she will search for endeavors or job positions where she can use her skills in full stack web development to build geospatial web applications for environmental sustainability and public awareness.