# QUAN TRỌNG: Làm rõ về NDVI và Phân loại Đất ## Mục tiêu chính: PHÂN LOẠI SỬ DỤNG ĐẤT Hệ thống phân loại 8 loại đất: 1. **Lua tom** (0): Lúa tôm 2. **Lua** (1): Lúa 3. **CHN** (2): Cây hàng năm 4. **CLN** (3): Cây lâu năm 5. **TS** (4): Thủy sản 6. **Song** (5): Sông 7. **Dat xay dung** (6): Đất xây dựng 8. **Rung** (7): Rừng ## Workflow Đúng ### Training: ``` Sentinel-2 Data (nhiều bands) → Extract Features (spectral bands, indices, temporal) → Train Model (RandomForest/XGBoost/CNN) → Model dự đoán loại đất (0-7) ``` ### Prediction: ``` Sentinel-2 Data (khu vực mới) → Extract Features (giống training) → Model.predict() → Kết quả: Bản đồ phân loại đất (0-7) → [OPTIONAL] Tính NDVI để visualization/analysis ``` ## NDVI là gì? **NDVI (Normalized Difference Vegetation Index)** là chỉ số thực vật: - Formula: `NDVI = (NIR - Red) / (NIR + Red)` - Giá trị: -1 đến +1 - Ý nghĩa: - Cao (>0.6): Thực vật xanh tươi (rừng, lúa) - Trung (0.2-0.6): Thực vật thưa, cỏ - Thấp (<0.2): Đất trống, nước, xây dựng ## Vai trò của NDVI ### ❌ KHÔNG PHẢI: Input duy nhất cho model ```python # SAI - Chỉ dùng NDVI để predict loại đất X = [ndvi_value] # 1 feature model.predict(X) # Accuracy thấp! ``` ### ✅ ĐÚNG: Một trong nhiều features ```python # ĐÚNG - Dùng nhiều features X = [ndvi, ndwi, ndbi, blue, green, red, nir, swir1, swir2, ...] # 39 features model.predict(X) # Accuracy cao! ``` ### ✅ ĐÚNG: Chỉ số phụ sau prediction ```python # 1. Predict land use predictions = model.predict(features) # → [0,1,2,3,4,5,6,7] # 2. Calculate NDVI for visualization ndvi = (nir - red) / (nir + red) # 3. Export both save_geotiff("land_classification.tif", predictions) save_geotiff("ndvi.tif", ndvi) # Chỉ số phụ để xem thêm ``` ## Model hiện tại: model_odc.joblib ```json { "n_features": 39, "model_type": "random_forest (GridSearchCV)", "purpose": "Phân loại sử dụng đất (8 classes)", "features": [ "Spectral bands từ nhiều time steps", "Spectral indices (NDVI, NDWI, NDBI, EVI, ...)", "Temporal features (min, max, mean, std, range)" ] } ``` ## So sánh với Notebook 01.train_ODC.ipynb Notebook này train model **ĐƠN GIẢN HÓA** chỉ để demo: - Chỉ dùng 1 feature (NDVI) - Accuracy thấp - **KHÔNG phải** model production Model thực tế (model_odc.joblib): - Dùng 39 features - Accuracy cao hơn - Production-ready ## Kết luận ✅ **Prediction workflow**: 1. Load Sentinel-2 data 2. Extract 39 features (bands + indices + temporal) 3. Model.predict() → Land classification map 4. [Optional] Calculate NDVI for additional analysis ✅ **NDVI role**: - Là MỘT trong các features (không phải duy nhất) - Hoặc là output phụ để visualization - KHÔNG phải mục tiêu chính ❌ **Sai lầm thường gặp**: - Nghĩ NDVI là input duy nhất - Train model chỉ với NDVI → accuracy thấp - Bỏ qua các features khác (NDWI, NDBI, temporal, ...)