3.1 KiB
3.1 KiB
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:
- Lua tom (0): Lúa tôm
- Lua (1): Lúa
- CHN (2): Cây hàng năm
- CLN (3): Cây lâu năm
- TS (4): Thủy sản
- Song (5): Sông
- Dat xay dung (6): Đất xây dựng
- 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
# 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
# ĐÚ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
# 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
{
"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:
- Load Sentinel-2 data
- Extract 39 features (bands + indices + temporal)
- Model.predict() → Land classification map
- [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, ...)