Skip to content

Soulemane12/Transit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NYC Transit Flood Monitor πŸš‡πŸŒŠ

A comprehensive predictive flood risk assessment system for NYC subway stations that combines real-time weather data, FEMA flood zones, stormwater modeling, and crowdsourced reports to predict flooding and suggest proactive mitigation strategies.

🎯 What it does

Core Features:

  • Predictive Risk Assessment: Machine learning model that calculates flood probability for each station
  • Interactive Risk Map: Color-coded subway stations by flood risk (green=safe, red=critical)
  • Time-based Forecasting: Slider to see risk predictions for T+1h, T+6h, T+12h, T+24h
  • Station Detail Panels: Comprehensive risk analysis with mitigation suggestions
  • Crowdsourced Reporting: Real-time flood reports from riders
  • Mitigation Planning: Cost-effective solutions with implementation timelines

πŸ—‚οΈ Data Sources

APIs & Datasets (all free/official):

  1. Subway Entrances/Exits: NYS/MTA entrances dataset with coordinates & metadata

  2. Stormwater Flood Polygons: NYC Stormwater Flood Maps (rainfall-based flooding)

  3. MTA Real-time Alerts: Live service disruptions and alerts

  4. Basemap & Visualization: Mapbox for interactive mapping

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Mapbox account (free tier available)

Installation

  1. Install dependencies

    npm install
  2. Set up environment variables

    cp .env.example .env.local

    Add your Mapbox token to .env.local:

    NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token_here
    

    Get a free token at: https://account.mapbox.com/access-tokens/

  3. Run the development server

    npm run dev
  4. Open your browser Navigate to http://localhost:3000

🧠 Predictive Modeling Approach

Features (Inputs):

  • Rainfall Intensity: Real-time and forecasted precipitation (inches/hour)
  • Station Elevation: Height above sea level for each entrance
  • Distance to Water: Proximity to nearest water body or storm drain
  • Land Cover: Impervious surface ratio in surrounding area
  • FEMA Flood Zone: Official flood risk classification
  • Drainage Capacity: Local stormwater infrastructure capacity
  • Historical Floods: Past flooding events at each station

Target (Outputs):

  • Flood Probability: 0-100% likelihood of flooding
  • Severity Score: 0-10 scale for flood impact
  • Time to Flood: Estimated minutes until flooding begins

Model Architecture:

  • Weighted Risk Calculation: Combines multiple factors with learned weights
  • Real-time Updates: Adjusts predictions based on current weather
  • Historical Learning: Incorporates past flood events for accuracy
  • Geospatial Analysis: Uses Turf.js for distance and intersection calculations

πŸ—οΈ Tech Stack

  • Frontend: Next.js 15, React 19, TypeScript
  • Mapping: Mapbox GL JS with custom risk visualization
  • Styling: Tailwind CSS with responsive design
  • Data Processing: Turf.js for geospatial calculations
  • Icons: Lucide React
  • Date Handling: date-fns
  • Predictive Modeling: Custom risk assessment algorithms

πŸ—ΊοΈ Features Overview

Interactive Map

  • Color-coded subway entrances by flood risk (red = high, orange = medium, green = low)
  • Flood zone overlays showing stormwater accumulation areas
  • Real-time alert markers for active flooding incidents
  • Clickable entrances for detailed information

Entrance Detail Panel

  • Flood risk assessment with exposure percentage
  • Active alerts (both MTA official and crowdsourced)
  • Suggested mitigation strategies with cost estimates
  • Crowdsourced flood reporting form

Dashboard Header

  • Key statistics: total entrances, high-risk count, active alerts
  • Real-time refresh capability
  • Last updated timestamp

Risk Assessment Algorithm

The flood risk calculation considers:

  • Proximity to stormwater flood zones
  • Historical flood depth data
  • Real-time weather and alert data
  • Entrance elevation and drainage characteristics

πŸ› οΈ Development

Project Structure

src/
β”œβ”€β”€ app/                    # Next.js app router
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ Dashboard.tsx      # Main dashboard component
β”‚   β”œβ”€β”€ FloodMap.tsx      # Mapbox map component
β”‚   β”œβ”€β”€ EntrancePanel.tsx # Side panel for entrance details
β”‚   └── StatusHeader.tsx  # Header with statistics
β”œβ”€β”€ lib/                   # Utilities and services
β”‚   β”œβ”€β”€ dataService.ts    # Data fetching and processing
β”‚   └── constants.ts      # Configuration constants
β”œβ”€β”€ types/                 # TypeScript type definitions
β”œβ”€β”€ data/                  # Mock data for development
└── app/api/              # API routes

Key Components

  • DataService: Centralized data fetching from NYC APIs
  • FloodMap: Mapbox integration with custom layers
  • EntrancePanel: Detailed view with mitigation suggestions
  • Risk Calculator: Geospatial analysis for flood exposure

πŸ”§ Customization

Adding New Data Sources

  1. Define types in src/types/index.ts
  2. Add API endpoints to src/lib/constants.ts
  3. Implement fetch logic in src/lib/dataService.ts
  4. Update visualization in src/components/FloodMap.tsx

Modifying Risk Calculations

Edit the calculateFloodRisk method in src/lib/dataService.ts to adjust:

  • Distance thresholds for flood zones
  • Weight factors for different risk types
  • Risk level boundaries

Adding Mitigation Options

Update MITIGATION_OPTIONS in src/lib/constants.ts with new suggestions including:

  • Cost estimates
  • Implementation timeframes
  • Effectiveness ratings

πŸ“± Mobile Support

The application is responsive and works on mobile devices with:

  • Touch-friendly map interactions
  • Responsive panel layouts
  • Optimized performance for mobile networks

πŸš€ Deployment

Vercel (Recommended)

  1. Connect your GitHub repository to Vercel
  2. Add environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Docker

# Build image
docker build -t transit-flood-monitor .

# Run container
docker run -p 3000:3000 transit-flood-monitor

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is open source and available under the MIT License.

πŸ†˜ Support

For questions or issues:

  1. Check existing GitHub issues
  2. Create a new issue with detailed description
  3. Include steps to reproduce any bugs

Built with ❀️ for NYC transit riders and flood resilience.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors