/CFC-Water-Ridgewood

The example Node-RED flows and dashboards can help you build a water quality dashboard using GeoJSON. After completing this tutorial, you will be ready to modify these example flows and dashboards to create your own map and data visualization solution.

Clean water and sanitation - Build a flow that displays the Ridgewood NJ watershed on a map

Workshop Resources

What is the problem?

Water is the natural resource that is most threatened by climate change and is a prerequisite for life on earth. According to the World Health Organization, 2.2 billion people around the world do not have safely managed drinking water services, 4.2 billion people do not have safely managed sanitation services, and 3 billion people lack basic handwashing facilities. These services are critical in preventing the spread of COVID-19 and other diseases. Even in areas that have these services, there are vast inequalities in the accessibility, availability, and quality of the services.

Video by our Call for Code Partner charity: water - The Spring - The charity: water story

Watch the video

How can technology solve the problem?

From intelligent solutions for small farmers to recycling showers, technology can make a significant impact on the availability of water and its consumption.

The idea

To encourage optimal water choices by consumers and local governments and to incentivize water sustainability, we propose devising and implementing an API for water data collection and dissemination. With an API, you could have a centralized way to:

  • Query geolocations of sustainable water sources
  • Simplify coordination and funding for water construction projects
  • Explore educational tools to support water sustainability and clean water access
  • Enable transparent water usage, cleanliness results, and site-to-site comparison
  • Access plain language case studies and legislation

We are initially focusing on the development of a starter kit that will enable these channels to be developed to their fullest potential.

Explore more ideas here

Architecture

Architecture

Tutorial

This tutorial is part of the 2021 Call for Code Global Challenge.

The example Node-RED flows and dashboards can help you build a water quality dashboard using GeoJSON. After completing this tutorial, you will be ready to modify these example flows and dashboards to create your own map and data visualization solution.

The Node-RED flows in this tutorial demonstrate how to display US Geological Survey (USGS) watershed maps on a Node-RED dashboard. Several examples describe how to query the watershed area maps of Ridgewood, NJ and Atlanta, GA using the USGS Hydro Network-Linked Data Index, and then plot the water basins and rivers on a Node-RED dashboard.

The USGS NLDI API returns a GeoJSON set of latitude / longitude coordinates and features that can be plotted using the node-red-contrib-web-worldmap node. To generate your own map, visit http://geojson.io which allows you to quickly generate a geojson file.

Water sustainability requires protecting the groundwater and sub-surface aquifer from dangerous / toxic pollutants. Aquagenuity helps everyday people monitor water quality in their community. The Aquagenuity Developer API provides water quality reports for many USA ZipCodes.

The following figure shows the Ridgewood NJ watershed dashboard:

Node-RED-Ridgewood-Watershed-flow

Learning objectives

In this tutorial, you will:

  • Install Node-RED and the prerequisites required to build the dashboards
  • Learn about GeoJSON
  • Learn how to query the US Geological Survey Watershed API
  • Integrate water quality reports into an application
  • Build a dashboard that displays GeoJSON area maps and pins

Prerequisites

Node-RED Essentials

Use the videos in this playlist to help you learn the basics of building Node-RED flows.

Estimated time

Completing this tutorial should take about 30 minutes.

Steps

Learn about GeoJSON

GeoJSON is a format for encoding a variety of geographic data structures. It is based on the JSON format. GeoJSON supports the following geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. Geometric objects with additional properties are Feature objects. Sets of features are contained by FeatureCollection objects.

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [58,24]
  },
  "properties": {
    "name": "Elbonia"
  }
}

The GeoJSON format can define a polygon which will render an area map of a town, county, or state, for example. Amongst its many uses, it can define the topographical boundary of a watershed.

Learn how to query the USGS Watershed API

The USGS NLDI API returns a GeoJSON set of latitude / longitude coordinates and features that can be plotted on a map. You can search for a river near you. The drainage basin is an area of land where surface water runs off and converges into streams, rivers, lakes, and oceans. Using the GeoJSON information to observe where water sources are located, and what contaminants might be upstream, can lead to better water management and quality.

The NLDI API is provided by the Open Water Data Initiative and is being developed as an open source project.

Here is an example which calls the USGS NLDI API to retrieve a GeoJSON object for the watershed basin for the Hohokus Brook upstream of Ridgewood, NJ.

curl https://labs.waterdata.usgs.gov/api/nldi/linked-data/nwissite/USGS-01391000/basin

If you were to plot the GeoJSON on a map with some fill properties, the map draws an area boundary.

Hohokus Brook watershed

Query the Aquagenuity GetWaterScore API

The Aquagenuity GetWaterScore API provides water quality reports for many USA ZipCodes. Sign up for a free Aquagenuity Developer API key. Select the free plan and create an account. You will receive an email welcoming you to the Aquagenuity Developer Access Program. The email will contain your username and password credentials.

Review the GetWaterScore api documentation to learn how to query water quality reports.

# Example Zipcode value of (07450)

curl --header "Content-Type: application/json" \
--request POST \
--data '{"auth":{"username":"XXXXXXXXX","password":"XXXXXXXXXX"},"zipcode":"07450"}' \
https://aquagenuity.com/GetWaterScore

The GetWaterScore API replies with a json object and array of contaminants in the water for that Zip Code. It also includes the EPA toxin limits and health risks of the toxins. Note the units of the returned values. If you have any questions about the API, contact Aquagenuity.

For this tutorial, the chemical toxins found in the water are displayed in a Node-RED table. If the toxins exceed the EPA limits, the table highlights the chemical in red and, when selected, will popup an informational dialog about the health risks of that toxin. USGS also publishes Water Quality Data

Final Output

Node-RED-Ridgewood-Watershed-dashboard

Workshop Resources