rubbish geo

09/16/2020 Data.

rubbish-geo is the (work-in-progress) backend to a forthcoming community litter map application.

In the summer of 2019 I did a freelance consulting project for Rubbish, a smart trash picker-upper startup. At the time they were interested in understanding what value they could derive from a rich collection of trash pickup data they had assembled.

One year later Rubbish's needs had advanced somewhat, and I was brought back in to build a geospatial analytics service that would allow the Rubbish team to build reports and community maps for stakeholders and community partners interested in understanding rubbish patterns in their neighborhoods.

This service diagram shows, at a high level, how it works. Basically, rubbish-geo is a serverless API over a PostGIS instance hosted on GCP. Litter pickups are written to the (preexisting) Firestore user database by the client, then pushed to the analytics database using a database listener. The records are cleaned, counted, and aligned to the street grid, creating a blockface-by-blockface view of street litter:


rubbish=#
SELECT (name, curb, rubbish_per_meter, num_runs)
    FROM blockface_statistics
    INNER JOIN centerlines
        ON blockface_statistics.centerline_id=centerlines.id;
row
--------------------------------------------------------------------------------
("Polk Street b/w Green Street and Union Street",left,0.22538216309912568,1)
("Polk Street b/w Green Street and Union Street",right,0.2863445870030898,1)
("Polk Street b/w Green Street and Bonita Street",right,0.44559654370508806,1)
("Polk Street b/w Green Street and Bonita Street",left,0.9923351948727908,1)
("Polk Street b/w Vallejo Street and Bonita Street",left,1.205936820807271,1)
("Polk Street b/w Vallejo Street and Bonita Street",right,1.003636792752386,1)
("Polk Street b/w Vallejo Street and Broadway",left,0.77333135587109,1)
("Polk Street b/w Vallejo Street and Broadway",right,1.0993923061952355,1)

Clients can then make GET requests (authenticated using Firestore custom tokens) to Cloud Function endpoints to retrieve litter reports.

The section architecture in the repo README has more information on how it works.

— Aleksey