bhuvanpatil24/rabi-ndvi-gis
1
πΎ Rabi Crop Prediction & NDVI Visualization
(GIS + Remote Sensing + Web Mapping)
A GIS-correct, production-ready web application for Rabi season crop analysis using NDVI time-series, cadastral (khasra) boundaries, and interactive web maps.
This project is designed for research, academic, and government-grade use cases, with strict adherence to GIS standards (CRS correctness, rasterβvector alignment, and spatial accuracy).
π Features
πΊοΈ Main Prediction Page
- OpenStreetMap basemap (EPSG:3857)
- NDVI stack overlay (GeoTIFF β PNG)
- Always-visible cadastral (khasra) polygons
- Optional khasra number labels (zoom-aware toggle)
- Click on map to:
- Identify khasra
- Show predicted Rabi crop
- Show actual crop (from shapefile)
- Display NDVI trend (NovβFeb)
π°οΈ NDVI & RGB Visualization Page
- Side-by-side RGB and NDVI maps
- Month selector: Nov, Dec, Jan, Feb
- Pixel-level NDVI value extraction
- Crop / No-crop legend
- Same cadastral overlay as main page
π Data & GIS Correctness
- NDVI GeoTIFFs in EPSG:32643 (UTM)
- Cadastral shapefile in EPSG:4326
- Proper CRS transformations (no CRS.Simple hacks)
- Raster sampling via Rasterio
- Vector operations via GeoPandas / Shapely
π§± Tech Stack
Backend
- FastAPI
- Rasterio (NDVI sampling)
- GeoPandas + Shapely (khasra polygons)
- PyProj (CRS transforms)
- Matplotlib (TIFF β PNG, server-side)
Frontend
- Vanilla HTML / CSS / JavaScript
- Leaflet.js
- Chart.js
- OpenStreetMap tiles
Deployment
- Docker
- Hugging Face Spaces
- Python 3.9 compatible
π Project Structure
rabi-ndvi-gis/
β
βββ backend/
β βββ models/
β βββ app.py # FastAPI app
β βββ model_utils.py
β βββ raster_utils.py # NDVI handling
β βββ ndvi_utils.py # Khasra logic
β
βββ frontend/
β βββ index.html
β βββ visualize.html
β βββ style.css
β βββ visualize.css
β βββ script.js
β βββ visualize.js
β
βββ data/
β βββ images/
β β βββ NDVI_STACK.tif
β βββ shapefiles/
β βββ rabi_updated.shp
β
βββ requirements.txt
βββ Dockerfile
βββ .dockerignore
βββ README.mdβοΈ Installation (Local Development)
1οΈβ£ Create virtual environment (Python 3.9)
python -m venv venv
source venv/bin/activate # Linux / Mac
venv\Scripts\activate # Windows2οΈβ£ Install dependencies
pip install -r requirements.txtβΆοΈ Run Locally
uvicorn backend.app:app --host 0.0.0.0 --port 8000Open in browser:
http://127.0.0.1:8000π§ Crop Classes
The system works with 5 standardized Rabi crop classes:
- ΰ€ΰ₯ΰ€ ΰ€«ΰ€Όΰ€Έΰ€² ΰ€¨ΰ€Ήΰ₯ΰ€ (No Crop)
- ΰ€ΰ€¨ΰ€Ύ (Gram)
- ΰ€ΰ₯ΰ€Ήΰ₯ΰ€ (Wheat)
- ΰ€Έΰ€°ΰ€Έΰ₯ΰ€ (Mustard)
- ΰ€ ΰ€¨ΰ₯ΰ€― ΰ€«ΰ€Έΰ€² (Other Crop)
Actual crop names from the shapefile are mapped internally to these classes.
π License
This project is intended for educational, research, and demonstration purposes. For government or commercial deployment, ensure proper data licensing.
π€ Author
Bhuvan Patil
GIS β’ Remote Sensing β’ Machine Learning β’ Web Mapping
