Interactive Flood Simulation & Infrastructure Planning Platform bootstrapped with Vite + React + TypeScript + Tailwind CSS.
- PRD-driven landing/dashboard shell for Flood Watch
- MapLibre map preview centered on Naga / Bicol with flood-depth visual overlays
- Scenario controls for Current, 5-year, 25-year, 50-year, and 100-year floods
- Infrastructure simulation cards for flood walls, retention basins, diversion channels, and pump stations
- Analytics cards for population, homes, roads, and economic exposure
- CesiumJS dependency and Vite integration ready for 3D terrain viewer work
- Dataset documentation for the BetterGov / Project NOAH PMTiles resource
Portal page: https://data.bettergov.ph/datasets/22/resources/416
Resource discovered from the portal:
- Name: Project NOAH Hazard Maps PMTiles
- Format:
VND.PMTILES - Size:
5.17 GB - Download: https://huggingface.co/datasets/bettergovph/project-noah-hazard-maps/resolve/main/PMTiles/noah_hazard_maps.pmtiles
- Source folder: https://huggingface.co/datasets/bettergovph/project-noah-hazard-maps/tree/main/PMTiles
The PMTiles file is intentionally not downloaded into git. When ready, store it under a local ignored data directory:
mkdir -p data/noah
curl -L -o data/noah/noah_hazard_maps.pmtiles \
https://huggingface.co/datasets/bettergovph/project-noah-hazard-maps/resolve/main/PMTiles/noah_hazard_maps.pmtilesFlood Watch mirrors the BetterGov DPWH project API into PostGIS for reliable latitude/longitude and bounding-box lookups. The downloaded project dump is intentionally not committed; local seed artifacts are written under ignored data/dpwh/.
sudo systemctl enable --now postgresql redis-server
createdb floodlens
psql postgres:///floodlens -f scripts/dpwh_postgis_schema.sql
./scripts/sync_dpwh_projects.pyThe sync downloads https://api.dpwh.bettergov.ph/projects into data/dpwh/dpwh_projects.jsonl and data/dpwh/dpwh_projects.csv, then bulk-loads dpwh_projects with a generated geom geometry(Point, 4326) column plus GiST/trigram indexes. The Vite dev API at /api/flood-control-projects reads from PostGIS and uses Redis for short-lived response caching.
-
Provision PostgreSQL 16+ with PostGIS and Redis near the app server.
-
Create the app database and extensions:
createdb floodlens psql "$DATABASE_URL" -f scripts/dpwh_postgis_schema.sqlIf the database user cannot create extensions, run this once as a superuser first:
CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS pg_trgm;
-
Run the mirror/import job from the application checkout:
export DATABASE_URL='postgres://USER:PASSWORD@HOST:5432/floodlens' ./scripts/sync_dpwh_projects.py --database-url "$DATABASE_URL" --out-dir /var/lib/floodlens/dpwh
Notes:
- Use a persistent
--out-diroutside the git checkout if you want to keep the raw JSONL/CSV snapshot for audit/re-import. - Re-running the script is safe: it upserts by
contract_id, updates changed records, and runsANALYZE. - For scheduled refreshes, run the same command from cron/systemd timer during low-traffic windows.
- Use a persistent
-
Verify row counts and geocoding coverage:
psql "$DATABASE_URL" -c "SELECT count(*) AS total_projects, count(*) FILTER (WHERE category = 'Flood Control and Drainage') AS flood_control, count(*) FILTER (WHERE geom IS NOT NULL) AS geocoded FROM dpwh_projects;"
-
Configure the app runtime:
export DATABASE_URL='postgres://USER:PASSWORD@HOST:5432/floodlens' export REDIS_URL='redis://REDIS_HOST:6379' export FLOODLENS_CACHE_SECONDS=60
-
If deploying the Project NOAH hazard map, download the PMTiles dataset separately on the server; do not commit it:
mkdir -p data/noah public/datasets curl -L -o data/noah/noah_hazard_maps.pmtiles \ https://huggingface.co/datasets/bettergovph/project-noah-hazard-maps/resolve/main/PMTiles/noah_hazard_maps.pmtiles ln -sfn ../../data/noah/noah_hazard_maps.pmtiles public/datasets/noah_hazard_maps.pmtiles
Default local services:
DATABASE_URL: unset uses the local Unix-socket databasefloodlens; set a Postgres URL to override.REDIS_URL: defaults toredis://127.0.0.1:6379.FLOODLENS_CACHE_SECONDS: defaults to60.
pnpm install
pnpm devUse a fixed port if needed:
PORT=5173 pnpm devpnpm build- Add
pmtilesprotocol support to MapLibre and render Project NOAH vector layers. - Define style layers for flood, landslide, and storm surge hazard classes.
- Add Cesium terrain provider and 3D fly-through view.
- Add property lookup using geocoding + elevation + hazard intersection API.
- Add backend services for PostGIS/GeoServer and Python/GDAL processing.
- Implement simplified water-routing simulation mode using DEM + rainfall inputs.