{"id":51177848,"url":"https://github.com/kaierikniermann/hormuz-crossing-tracker","last_synced_at":"2026-06-27T05:01:03.973Z","repository":{"id":344148240,"uuid":"1180657602","full_name":"KaiErikNiermann/hormuz-crossing-tracker","owner":"KaiErikNiermann","description":"Maritime vessel passage tracker for the Strait of Hormuz - combines GFW satellite data with live AIS streams. Updated every 5 days.","archived":false,"fork":false,"pushed_at":"2026-03-13T14:23:45.000Z","size":2227,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-13T20:58:18.875Z","etag":null,"topics":["ais-data","gfw-data","hormuz","oil-prices","strait-of-hormuz","vessel-tracking"],"latest_commit_sha":null,"homepage":"https://kaierikniermann.github.io/hormuz-crossing-tracker/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KaiErikNiermann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-13T09:16:39.000Z","updated_at":"2026-03-13T14:23:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/KaiErikNiermann/hormuz-crossing-tracker","commit_stats":null,"previous_names":["kaierikniermann/hormuz-crossing-tracker"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/KaiErikNiermann/hormuz-crossing-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaiErikNiermann%2Fhormuz-crossing-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaiErikNiermann%2Fhormuz-crossing-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaiErikNiermann%2Fhormuz-crossing-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaiErikNiermann%2Fhormuz-crossing-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KaiErikNiermann","download_url":"https://codeload.github.com/KaiErikNiermann/hormuz-crossing-tracker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaiErikNiermann%2Fhormuz-crossing-tracker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34841990,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ais-data","gfw-data","hormuz","oil-prices","strait-of-hormuz","vessel-tracking"],"created_at":"2026-06-27T05:00:46.579Z","updated_at":"2026-06-27T05:01:03.943Z","avatar_url":"https://github.com/KaiErikNiermann.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strait of Hormuz — Maritime Passage Tracker\n\nA real-time vessel tracking dashboard for the Strait of Hormuz, combining [Global Fishing Watch](https://globalfishingwatch.org/) satellite data with live AIS streams.\n\nTracks vessel movements, classifies strait crossings (inbound/outbound), and visualizes daily traffic patterns through an interactive MapLibre GL map with historical playback.\n\n## Features\n\n- **Live AIS tracking** via [AISStream](https://aisstream.io/) WebSocket — persistent vessel monitoring with crossing detection\n- **GFW satellite data** — 30-day historical vessel presence (AIS grid + SAR detections)\n- **MMSI-based deduplication** — merges GFW and live AIS, tagging vessels as `gfw`, `ais`, or `both`\n- **Interactive map** — MapLibre GL with directional arrow markers, vessel trails, TSS shipping lanes, and geofence zones\n- **Timeline playback** — slider through 30 days of daily vessel positions\n- **Crossings chart** — stacked bar chart (Observable Plot) with LOESS trend line, switchable between direction and vessel type views\n- **Data source toggle** — filter view by ALL / GFW / AIS\n- **Light/dark theme** — CartoDB Positron/Dark Matter basemaps\n\n## Architecture\n\n```mermaid\nflowchart TD\n    AIS[\"AISStream WebSocket\"] -- live positions --\u003e Worker[\"AIS Worker\"]\n    Worker -- state \u0026 events --\u003e DB[\"PostgreSQL\"]\n    GFW[\"GFW 4Wings API\"] -- vessel presence --\u003e Fetch[\"fetch_gfw.py\"]\n    Fetch --\u003e GFWFile[\"gfw_timeline.json\"]\n    DB --\u003e Merge[\"export_snapshot.py\"]\n    GFWFile --\u003e Merge\n    Merge --\u003e Timeline[\"vessels_timeline.json\"]\n    Timeline --\u003e Site[\"Static Site (MapLibre GL)\"]\n```\n\n## Quick Start\n\n### Prerequisites\n\n- Python 3.12+\n- [Poetry](https://python-poetry.org/)\n- [pnpm](https://pnpm.io/)\n- Docker \u0026 Docker Compose\n- API keys: [AISStream](https://aisstream.io/) and [Global Fishing Watch](https://globalfishingwatch.org/our-apis/)\n\n### 1. Clone and install\n\n```bash\ngit clone https://github.com/yourusername/strait-of-hormuz.git\ncd strait-of-hormuz\n\n# Python dependencies\npoetry install\n\n# Frontend dependencies\ncd site \u0026\u0026 pnpm install \u0026\u0026 cd ..\n```\n\n### 2. Configure environment\n\n```bash\ncp .env.example .env\n# Edit .env with your API keys:\n#   AISSTREAM_API_KEY=...\n#   GFW_API_ACCESS_TOKEN=...\n```\n\n### 3. Start the stack\n\n```bash\n# Start PostgreSQL + all workers (AIS tracker + GFW fetcher)\ndocker compose up -d\n\n# Check workers are running\ndocker compose logs worker --tail 20\n```\n\n### 4. Build and serve the frontend\n\n```bash\ncd site\npnpm run build          # one-time build\npnpm run watch          # or dev watch mode\n\n# Serve the site\npython3 -m http.server 8090\n```\n\nOpen [http://localhost:8090](http://localhost:8090).\n\n## Running Without Docker\n\nIf you prefer running the workers directly:\n\n```bash\n# Start PostgreSQL separately, then:\nexport HORMUZ_DB_HOST=localhost HORMUZ_DB_PORT=5432\nexport HORMUZ_DB_NAME=hormuz HORMUZ_DB_USER=hormuz HORMUZ_DB_PASSWORD=hormuz\n\n# Fetch GFW data (one-off)\npoetry run fetch-gfw\n\n# Start live AIS tracker\npoetry run tracker\n\n# Merge GFW + AIS into site data\npoetry run export-snapshot\n```\n\n## Project Structure\n\n```\nstrait-of-hormuz/\n├── worker/\n│   ├── maritime_passages_live.py   # Live AIS WebSocket tracker\n│   ├── gfw_periodic_fetch.py       # Periodic GFW fetcher (every 5 days)\n│   ├── persistent_workers.py       # Worker supervisor with auto-restart\n│   └── db.py                       # PostgreSQL connection helper\n├── scripts/\n│   ├── fetch_gfw.py                # GFW API data pipeline\n│   ├── export_snapshot.py          # Merge GFW + AIS → vessels_timeline.json\n│   └── snapshot_ais.py             # Quick AIS snapshot utility\n├── site/\n│   ├── src/app.ts                  # Frontend application (TypeScript)\n│   ├── index.html                  # Main page\n│   ├── style.css                   # Styles (light/dark themes)\n│   └── data/                       # Generated data files (gitignored)\n├── config.yaml                     # Passage definitions and tracker settings\n├── docker-compose.yml              # PostgreSQL + Worker services\n├── Dockerfile.worker               # Worker container image\n└── pyproject.toml                  # Python dependencies and scripts\n```\n\n## Data Pipeline\n\n| Step | Script | Input | Output | Schedule |\n|------|--------|-------|--------|----------|\n| GFW fetch | `fetch_gfw.py` | GFW 4Wings API | `gfw_timeline.json` | Every 5 days |\n| AIS tracking | `maritime_passages_live.py` | AISStream WebSocket | PostgreSQL tables | Continuous |\n| Merge \u0026 export | `export_snapshot.py` | `gfw_timeline.json` + PostgreSQL | `vessels_timeline.json` | After GFW fetch |\n\n## Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `AISSTREAM_API_KEY` | Yes | AISStream WebSocket API key |\n| `GFW_API_ACCESS_TOKEN` | Yes | Global Fishing Watch API token |\n| `HORMUZ_DB_HOST` | No | PostgreSQL host (default: `localhost`) |\n| `HORMUZ_DB_PORT` | No | PostgreSQL port (default: `5432`) |\n| `HORMUZ_DB_NAME` | No | Database name (default: `hormuz`) |\n| `HORMUZ_DB_USER` | No | Database user (default: `hormuz`) |\n| `HORMUZ_DB_PASSWORD` | No | Database password (default: `hormuz`) |\n| `GFW_FETCH_INTERVAL_HOURS` | No | Hours between GFW fetches (default: `120`) |\n| `PERSISTENT_TRACKERS` | No | Comma-separated worker names (default: `maritime-passages-live,gfw-periodic-fetch`) |\n\n## Methodology\n\n### How crossings are detected\n\nA **crossing** is recorded when a vessel moves between the west approach zone (Persian Gulf side) and the east approach zone (Gulf of Oman side) of the strait.\n\n| | Live AIS | GFW Historical |\n|---|---|---|\n| **Method** | Two-zone state machine: vessel enters zone A, then appears in zone B | Day-to-day longitude transition across 56.5°E meridian |\n| **Window** | Must complete within 18 hours | Consecutive calendar days |\n| **Dedup** | 6-hour minimum gap between events per vessel | 1 crossing per vessel per day max |\n| **Resolution** | Real-time (seconds) | Daily (24h UTC aggregate) |\n\n**Inbound** = east to west (entering Persian Gulf). **Outbound** = west to east (leaving toward Gulf of Oman).\n\n### Daily snapshot timing\n\nEach date on the timeline represents a **full 24-hour UTC day** as aggregated by GFW — one record per vessel per day, no duplicates. Positions are **snapped to a spatial grid** (not precise GPS), representing the grid cell where the vessel was detected. Vessels in the same cell appear as overlapping markers. The `hours` field indicates detection duration (2h = passing through, 20h = anchored). GFW data has a **~5-day lag** from the current date. Live AIS is real-time but only merged into dates with existing GFW coverage.\n\n### Limitations\n\n- Vessels can disable AIS transponders (\"go dark\"), especially in conflict zones\n- GFW daily positions are aggregated — exact transit time within a day is unknown\n- Small vessels without AIS class A/B transponders are not tracked\n- AIS spoofing (false position reports) can occur in this region\n\n## Data Sources\n\n- **[Global Fishing Watch](https://globalfishingwatch.org/)** — Satellite-derived vessel presence (AIS + SAR)\n- **[AISStream](https://aisstream.io/)** — Real-time AIS position reports via WebSocket\n- **Basemaps** — [CARTO](https://carto.com/) Positron and Dark Matter via MapLibre GL\n\n## Data Releases\n\nCumulative and rolling 30-day data snapshots are published as [GitHub Releases](../../releases) on each rebuild cycle (~every 5 days). Each release includes:\n\n- `vessels_timeline.json` — Full cumulative GFW + AIS merged timeline\n- `vessels_timeline_30d.json` — Rolling 30-day batch\n- `gfw_timeline.json` — GFW-only timeline\n- `vessels.json` — Flat vessel metadata snapshot\n\n## License\n\n- **Code**: [GPL-3.0](LICENSE)\n- **Data**: See [DATA_LICENSE.md](DATA_LICENSE.md) — GFW data is [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) (non-commercial only, attribution required), AIS data is from public broadcasts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaierikniermann%2Fhormuz-crossing-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaierikniermann%2Fhormuz-crossing-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaierikniermann%2Fhormuz-crossing-tracker/lists"}