An interactive web application for visualizing internal migration flows across Indian states with dynamic boundary loading and detailed migration analytics.
- Interactive Migration Map: Visualize in-migration (blue), out-migration (red), and net migration (white dashed) flows
- Dynamic Boundary Loading: 10 levels of geometric simplification based on zoom level
- State Selection: Click on states or flows to highlight related migration patterns
- Detailed Analytics: Side panel showing detailed migration data for selected states
- Filter Controls: Toggle different flow types and adjust minimum flow thresholds
- Keyboard Navigation: Press ESC to deselect and return to hover mode
- Backend: Flask with Python
- Frontend: Leaflet.js, HTML5, CSS3, JavaScript
- Data Processing: Pandas, GeoPandas, Shapely
- Dependencies Management: uv (Python package manager)
- Python 3.12+
- uv package manager
- Clone the repository:
git clone https://github.com/amitportal/india_internal_migration_mapping.git
cd india_internal_migration_mapping- Install dependencies using uv:
uv syncThe application requires the following data files in the root directory:
IND_5yrs_InternalMigFlows_2010.csv- Migration flow dataindia_states.geojson- Indian state boundaries
- Run the application:
uv run python app.py- Open your browser and navigate to
http://localhost:5000
The application expects a CSV file with the following columns:
ISO: Country identifierNODEJ: Origin node IDNODEI: Destination node IDLONFR,LATFR: Origin coordinatesLONTO,LATTO: Destination coordinatesPrdMIG: Migration volume
State boundaries should be in GeoJSON format with:
state: State namecountry: Country name (should be "India")geometry: State boundary geometry
- Hover: Shows state names and highlights related flows (when no selection is active)
- Click on State: Highlights all flows to/from that state, shows detailed information
- Click on Flow: Highlights all three flow types (in, out, net) between the two states
- ESC Key: Deselects current selection and enables hover functionality
- Zoom: Dynamically loads boundaries with appropriate detail level
- Red Lines: Out-migration flows (from origin state to destination)
- Blue Lines: In-migration flows (to destination state from origin)
- White Dashed Lines: Net migration flows (balance between in and out migration)
- Toggle flow types (in-migration, out-migration, net migration)
- Adjust minimum flow size with slider
- Reset highlighting functionality
The application follows a client-server architecture:
- Handles data loading and processing
- Provides API endpoints for:
- Boundary data with zoom-level appropriate simplification
- Migration flow data
- State-specific migration details
- Overall statistics
- Interactive map interface
- Dynamic loading of data based on zoom level
- Flow visualization with Bezier curves
- Selection and highlighting logic
The application uses 10 zoom levels with the following simplification factors:
- Level 1 (zoomed out): 5.0 (highest simplification)
- Level 10 (zoomed in): 0.5 (lowest simplification, most detail)
- Extend the Flask API in
app.pyfor backend functionality - Update the JavaScript in
templates/index.htmlfor frontend interactions - Consider the selection priority system (click > hover) when adding new interactions
- The 10-level simplification system balances detail and performance
- Flow rendering is limited to prevent visual clutter
- Boundary loading is optimized based on current zoom level
The following Python packages are required:
- Flask: Web framework
- pandas: Data manipulation
- geopandas: Geospatial data processing
- shapely: Geometric operations
- numpy: Numerical operations
- uv: Package manager
GET /- Main application pageGET /api/boundaries?zoom={level}- State boundaries for zoom levelGET /api/flows?min_flow={threshold}- Migration flows above thresholdGET /api/net_migration?min_flow={threshold}- Net migration flowsGET /api/state_migration/{state_name}- Detailed migration data for stateGET /api/stats- Overall migration statistics
- Missing Data Files: Ensure
IND_5yrs_InternalMigFlows_2010.csvandindia_states.geojsonare in the root directory - Performance: Large zoom levels or high flow thresholds may affect performance
- Coordinate Systems: All data should use EPSG:4326 (WGS 84) coordinate system
- Modern browsers with JavaScript enabled
- Supports major browsers including Chrome, Firefox, Safari, Edge
This project is released under the MIT License. See the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Caching for boundaries and Bezier curve calculations
- Additional filtering options
- Export functionality
- Time-series visualization
- Additional geographic projections
- Amit Kumar
- Migration data for research and analysis purposes
- Leaflet.js for interactive mapping capabilities
- OpenStreetMap for base map tiles