Skip to main content

Open-source cloud-native geospatial Python package for residential waste collection analytics.

Project description

opentrash

Open-source, cloud-native geospatial Python package for residential waste collection analytics. Turn months of vehicle telematics into per-parcel service signatures and per-day interactive route maps.

PyPI Python License Docs

opentrash is a Python package for waste-collection agencies, civic technologists, and researchers studying urban operations. It ingests GPS telematics + parcel polygons + route polygons + facility locations, performs one disciplined spatial-join pass (the engine), and then produces two analytical products on top:

  • Patterns — per-parcel service signatures (weekly1, weekly2, biweekly) derived from months or years of pings. Answers "for this parcel, who shows up regularly, on what day, at what hour?"
  • RouteView — a self-contained interactive HTML map for one (route, day, vehicle). Shows the truck's trail as colored GPS dots, parcels colored served vs. missed, the patterns expectation overlaid on today's reality. Drop it on a USB stick, email it, host it static.

The architecture is "spatial joins are infrastructure; products are calculations." Everything downstream of the engine is pure aggregation on enriched pings.

Install

pip install opentrash

Optional extras for specific data sources:

pip install "opentrash[geotab]"     # Geotab GPS adapter
pip install "opentrash[postgres]"   # PostgreSQL/PostGIS GPS adapter
pip install "opentrash[dev]"        # pytest, ruff for development

Requires Python 3.11 or newer.

Quickstart

from datetime import date
from opentrash.engine.enrichment import enrich_pings
from opentrash.patterns.runner import run_patterns
from opentrash.routeview.runner import render_routeview

# 1. Enrich GPS pings with routes, parcels, facilities (one spatial-join pass).
enrich_pings(
    gps_cache_root="cache/",
    parcels_wkb_path="prep/parcels_wkb.parquet",
    routes_path="prep/routes.parquet",
    facilities_path="prep/facilities.parquet",
    out_root="enriched/",
    day="2026-01-18",
)

# 2. Detect per-parcel patterns over the past year.
run_patterns(
    enriched_root="enriched/",
    parcels_wkb_path="prep/parcels_wkb.parquet",
    out_root="patterns/",
    period="past_year",
)

# 3. Render an interactive HTML for one route + day + vehicle.
render_routeview(
    enriched_root="enriched/",
    segments_root="segments/",
    parcels_wkb_path="prep/parcels_wkb.parquet",
    routes_path="prep/routes.parquet",
    facilities_path="prep/facilities.parquet",
    out_root="routeview/",
    route_id="11722",
    day=date(2026, 1, 18),
    vehicle_id="815001",
    patterns_root="patterns/",
    patterns_window="2025-01-18_to_2026-01-18",
)

The output is a single self-contained .html file at routeview/2026-01-18/11722__815001.html. Open it in any browser.

Architecture

GPS ingest  →  cache  →  engine (the only spatial-join layer)
                            │
                            ↓ enriched pings
                            │
                ┌───────────┴───────────┐
                ↓                       ↓
        patterns (macro)          segments (timeline)
        per-parcel signatures           │
        across the window              ↓
                                  RouteView (micro)
                                  one (route, day, vehicle)
                                  as an interactive HTML

Patterns is the macro view; RouteView is the micro view. Together they form a validation loop: the long-period patterns predict who should show up; the single-day RouteView shows who actually did.

Documentation

How it's built

opentrash uses DuckDB for the heavy aggregations (set-based SQL, chunked + idempotent for large datasets), GeoPandas + Shapely for in-memory geometry work, PyProj for projections, and MapLibre GL JS for the rendered HTML maps. No commercial dependencies, no tile-provider lock-in.

License

Apache License 2.0 — see LICENSE and NOTICE.

You may use, modify, and redistribute opentrash for any purpose, including commercial use, provided you retain the license and copyright notices. Maximum adoption is the goal — spreading the knowledge.

Citation

If you use opentrash in academic work, please cite it via the metadata in CITATION.cff (also available as a "Cite this repository" button on GitHub once the repository is public).

Acknowledgments

Built by Mohamad Alsheikh Yassin under AI Research Corps (AIRC), a 501(c)(3) nonprofit. The original system was prototyped during my time at the City of San Diego; the open-source rewrite, documentation, and course material were produced independently at AIRC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentrash-0.1.0.tar.gz (112.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentrash-0.1.0-py3-none-any.whl (101.0 kB view details)

Uploaded Python 3

File details

Details for the file opentrash-0.1.0.tar.gz.

File metadata

  • Download URL: opentrash-0.1.0.tar.gz
  • Upload date:
  • Size: 112.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentrash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1eac2e63f9d43d033887a5c1cfc0b0a56c553bd265ea49deda9c517a697224f
MD5 2e179fb554722b03f5a1c80cbe9245de
BLAKE2b-256 602be1f4114b60424c4e9b978b599f6923eebf5e23b08763a2e50d415e3305a0

See more details on using hashes here.

File details

Details for the file opentrash-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opentrash-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 101.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentrash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3482b7a04c1652f8a2d1cf8f4fa2a819fff754a2ee3aa80bfe57754eb03e8856
MD5 8e113bc819f16f45ab8efd54e831c31b
BLAKE2b-256 8028da11b6441918743a55e1ae41695872e27b4124e0c2cedfee70889ca1e8bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page