# Crop Analysis Messaging Decision Flowchart
This flowchart visualizes the enhanced decision logic for automated crop analysis messaging based on field uniformity, spatial patterns, CI change trends, and acceptable area thresholds.
## Decision Flow
```mermaid
flowchart TD
Start([Weekly CI Analysis Starts]) --> Extract[Extract CI values from satellite mosaics]
Extract --> CalcStats[Calculate field statistics:
- Mean CI
- Coefficient of Variation CV
- Acceptable area percent
- Spatial autocorrelation Morans I]
CalcStats --> CompareWeeks[Compare current week vs previous week]
CompareWeeks --> CalcChange[Calculate CI Change:
Current minus Previous]
CalcChange --> CategorizeChange{Categorize CI Change}
CategorizeChange -->|Change ≥ +0.5| Increase[CI Increase]
CategorizeChange -->|-0.5 < Change < +0.5| Stable[CI Stable]
CategorizeChange -->|Change ≤ -0.5| Decrease[CI Decrease]
Increase --> CheckUniformity1{Enhanced Uniformity Check:
CV and Acceptable Area}
Stable --> CheckUniformity2{Enhanced Uniformity Check:
CV and Acceptable Area}
Decrease --> CheckUniformity3{Enhanced Uniformity Check:
CV and Acceptable Area}
%% Enhanced uniformity categorization
CheckUniformity1 -->|CV > 0.25 OR
Acceptable < 40| PoorUniformity1[POOR UNIFORMITY
Urgent attention needed]
CheckUniformity1 -->|CV ≤ 0.08 AND
Acceptable ≥ 45| ExcellentUniformity1[EXCELLENT UNIFORMITY
Optimal field condition]
CheckUniformity1 -->|CV ≤ 0.15| GoodUniformity1[GOOD UNIFORMITY
Check for clustering]
CheckUniformity1 -->|0.15 < CV ≤ 0.25| ModerateVariation1[MODERATE VARIATION
Needs investigation]
CheckUniformity2 -->|CV > 0.25 OR
Acceptable < 40| PoorUniformity2[POOR UNIFORMITY
Urgent attention needed]
CheckUniformity2 -->|CV ≤ 0.08 AND
Acceptable ≥ 45| ExcellentUniformity2[EXCELLENT UNIFORMITY
Optimal field condition]
CheckUniformity2 -->|CV ≤ 0.15| GoodUniformity2[GOOD UNIFORMITY
Check for clustering]
CheckUniformity2 -->|0.15 < CV ≤ 0.25| ModerateVariation2[MODERATE VARIATION
Needs investigation]
CheckUniformity3 -->|CV > 0.25 OR
Acceptable < 40| PoorUniformity3[POOR UNIFORMITY
Urgent attention needed]
CheckUniformity3 -->|CV ≤ 0.08 AND
Acceptable ≥ 45| ExcellentUniformity3[EXCELLENT UNIFORMITY
Optimal field condition]
CheckUniformity3 -->|CV ≤ 0.15| GoodUniformity3[GOOD UNIFORMITY
Check for clustering]
CheckUniformity3 -->|0.15 < CV ≤ 0.25| ModerateVariation3[MODERATE VARIATION
Needs investigation]
%% Spatial analysis for good uniformity fields
GoodUniformity1 --> SpatialCheck1{Morans I > 0.95?
Very strong clustering}
GoodUniformity2 --> SpatialCheck2{Morans I > 0.95?
Very strong clustering}
GoodUniformity3 --> SpatialCheck3{Morans I > 0.95?
Very strong clustering}
%% Clustering analysis for good uniformity
SpatialCheck1 -->|Yes| HighClustering1[VERY HIGH CLUSTERING
Potential growth zones]
SpatialCheck1 -->|No| OptimalField1[EXCELLENT FIELD
Uniform and well-distributed]
SpatialCheck2 -->|Yes| HighClustering2[VERY HIGH CLUSTERING
Potential growth zones]
SpatialCheck2 -->|No| OptimalField2[EXCELLENT FIELD
Uniform and well-distributed]
SpatialCheck3 -->|Yes| HighClustering3[VERY HIGH CLUSTERING
Potential growth zones]
SpatialCheck3 -->|No| OptimalField3[EXCELLENT FIELD
Uniform and well-distributed]
%% Spatial pattern analysis for moderate variation fields
ModerateVariation1 --> SpatialAnalysis1[Spatial Analysis:
Morans I autocorrelation]
ModerateVariation2 --> SpatialAnalysis2[Spatial Analysis:
Morans I autocorrelation]
ModerateVariation3 --> SpatialAnalysis3[Spatial Analysis:
Morans I autocorrelation]
SpatialAnalysis1 --> ClassifyVariation1{Spatial Pattern?}
SpatialAnalysis2 --> ClassifyVariation2{Spatial Pattern?}
SpatialAnalysis3 --> ClassifyVariation3{Spatial Pattern?}
%% Localized vs distributed variation outcomes
ClassifyVariation1 -->|Morans I > 0.95
Very Clustered| LocalizedInc[Localized Growth Zones
plus CI Increase]
ClassifyVariation1 -->|Morans I ≤ 0.95
Normal Random| DistributedInc[Field-wide Variation
plus CI Increase]
ClassifyVariation2 -->|Morans I > 0.95
Very Clustered| LocalizedStable[Localized Growth Zones
plus CI Stable]
ClassifyVariation2 -->|Morans I ≤ 0.95
Normal Random| DistributedStable[Field-wide Variation
plus CI Stable]
ClassifyVariation3 -->|Morans I > 0.95
Very Clustered| LocalizedDec[Localized Problem Zones
plus CI Decrease]
ClassifyVariation3 -->|Morans I ≤ 0.95
Normal Random| DistributedDec[Field-wide Variation
plus CI Decrease]
%% Excellent and good uniformity outcomes
ExcellentUniformity1 --> NoAlert1[NO ALERT
Excellent field condition]
ExcellentUniformity2 --> NoAlert2[NO ALERT
Excellent field condition]
ExcellentUniformity3 --> NoAlert3[NO ALERT
Excellent field condition]
HighClustering1 --> Alert1[CLUSTERING NOTED
Growth zones detected]
HighClustering2 --> Alert2[CLUSTERING NOTED
Growth zones detected]
HighClustering3 --> Alert3[CLUSTERING NOTED
Growth zones detected]
OptimalField1 --> NoAlert1
OptimalField2 --> NoAlert2
OptimalField3 --> NoAlert3
%% Poor uniformity outcomes
PoorUniformity1 --> Alert4[URGENT ATTENTION
Poor field uniformity]
PoorUniformity2 --> Alert5[URGENT ATTENTION
Poor field uniformity]
PoorUniformity3 --> Alert6[URGENT ATTENTION
Poor field uniformity]
%% Enhanced message outcomes for moderate variation
LocalizedInc --> Alert7[INVESTIGATION
Growth zones plus CI increase]
DistributedInc --> Alert8[INVESTIGATION
Field-wide variation plus CI increase]
LocalizedStable --> Alert9[SEND ALERT
Problem zones detected - investigate]
DistributedStable --> Alert10[SEND ALERT
Field-wide unevenness - check practices]
LocalizedDec --> Alert11[HIGH PRIORITY
Declining zones - immediate action needed]
DistributedDec --> Alert12[HIGH PRIORITY
Field declining overall - review management]
%% Final outcomes
Alert1 --> SendMessage1[Send Clustering Note]
Alert2 --> SendMessage2[Send Clustering Note]
Alert3 --> SendMessage3[Send Clustering Note]
Alert4 --> SendMessage4[Send Urgent Field Alert]
Alert5 --> SendMessage5[Send Urgent Field Alert]
Alert6 --> SendMessage6[Send Urgent Field Alert]
Alert7 --> SendMessage7[Send Investigation Alert]
Alert8 --> SendMessage8[Send Investigation Alert]
Alert9 --> SendMessage9[Send Problem Zone Alert]
Alert10 --> SendMessage10[Send Field Management Alert]
Alert11 --> SendMessage11[Send Urgent Zone Alert]
Alert12 --> SendMessage12[Send Urgent Management Alert]
NoAlert1 --> NoAction[Log for monitoring only]
NoAlert2 --> NoAction
NoAlert3 --> NoAction
SendMessage1 --> End([End: Message Generated])
SendMessage2 --> End
SendMessage3 --> End
SendMessage4 --> End
SendMessage5 --> End
SendMessage6 --> End
SendMessage7 --> End
SendMessage8 --> End
SendMessage9 --> End
SendMessage10 --> End
SendMessage11 --> End
SendMessage12 --> End
NoAction --> End2([End: No Action Required])
%% Styling
classDef alertBox fill:#ffcccc,stroke:#ff0000,stroke-width:2px
classDef urgentBox fill:#ff9999,stroke:#cc0000,stroke-width:3px
classDef clusterBox fill:#ffeaa7,stroke:#fdcb6e,stroke-width:2px
classDef noAlertBox fill:#ccffcc,stroke:#00ff00,stroke-width:2px
classDef decisionBox fill:#fff2cc,stroke:#d6b656,stroke-width:2px
classDef processBox fill:#dae8fc,stroke:#6c8ebf,stroke-width:2px
classDef spatialBox fill:#e1d5e7,stroke:#9673a6,stroke-width:2px
classDef excellentBox fill:#a8e6cf,stroke:#558b2f,stroke-width:2px
classDef poorBox fill:#ffcdd2,stroke:#d32f2f,stroke-width:3px
class Alert9,Alert10,SendMessage9,SendMessage10 alertBox
class Alert4,Alert5,Alert6,Alert11,Alert12,SendMessage4,SendMessage5,SendMessage6,SendMessage11,SendMessage12 urgentBox
class Alert1,Alert2,Alert3,Alert7,Alert8,SendMessage1,SendMessage2,SendMessage3,SendMessage7,SendMessage8 clusterBox
class NoAlert1,NoAlert2,NoAlert3,NoAction noAlertBox
class CategorizeChange,CheckUniformity1,CheckUniformity2,CheckUniformity3,ClassifyVariation1,ClassifyVariation2,ClassifyVariation3,SpatialCheck1,SpatialCheck2,SpatialCheck3 decisionBox
class Extract,CalcStats,CompareWeeks,CalcChange processBox
class SpatialAnalysis1,SpatialAnalysis2,SpatialAnalysis3 spatialBox
class ExcellentUniformity1,ExcellentUniformity2,ExcellentUniformity3,OptimalField1,OptimalField2,OptimalField3 excellentBox
class PoorUniformity1,PoorUniformity2,PoorUniformity3 poorBox
```
## Enhanced Decision Matrix with Spatial Analysis
| Uniformity Category | CV Range | Acceptable Area % | Spatial Pattern | CI Change | Message | Alert Level |
|---------------------|----------|-------------------|-----------------|-----------|---------|-------------|
| **Excellent** | ≤ 0.08 | ≥ 45% | Normal (≤0.95) | Any | Excellent field condition | ❌ None |
| **Excellent** | ≤ 0.08 | ≥ 45% | High clustering (>0.95) | Any | Growth zones detected | 🔶 Clustering Note |
| **Good** | ≤ 0.15 | ≥ 45% | Normal (≤0.95) | Any | Good uniformity, well-distributed | ❌ None |
| **Good** | ≤ 0.15 | ≥ 45% | High clustering (>0.95) | Any | Potential growth zones | 🔶 Clustering Note |
| **Moderate** | 0.15-0.25 | 40-45% | Normal (≤0.95) | Increase | Field-wide variation + CI increase | 🔶 Investigation |
| **Moderate** | 0.15-0.25 | 40-45% | Normal (≤0.95) | Stable | Field-wide unevenness - check practices | 🚨 Alert |
| **Moderate** | 0.15-0.25 | 40-45% | Normal (≤0.95) | Decrease | Field declining overall - review management | 🚨🚨 Urgent |
| **Moderate** | 0.15-0.25 | 40-45% | High clustering (>0.95) | Increase | Growth zones + CI increase | 🔶 Investigation |
| **Moderate** | 0.15-0.25 | 40-45% | High clustering (>0.95) | Stable | Problem zones detected - investigate | 🚨 Alert |
| **Moderate** | 0.15-0.25 | 40-45% | High clustering (>0.95) | Decrease | Declining zones - immediate action needed | 🚨🚨 Urgent |
| **Poor** | > 0.25 | < 40% | Any | Any | Poor field uniformity - urgent attention | 🚨🚨 Urgent |
## Spatial Analysis Methods
### 1. **Moran's I Spatial Autocorrelation**
- **Purpose**: Determines if similar CI values cluster together spatially
- **Agricultural Context**: High values (>0.95) indicate very strong clustering, which is noteworthy in agricultural fields where some clustering is natural
- **Threshold**: > 0.95 for "very high clustering" (potential growth zones or problem areas)
- **Calculation**: Compares each pixel's value to its spatial neighbors using queen contiguity
### 2. **Simple Extreme Detection (Mean ± 1.5 × SD)**
- **Purpose**: Identifies pixels with values significantly above or below the field average
- **Method**: Values outside mean ± 1.5 standard deviations are considered extremes
- **Agricultural Relevance**: More interpretable than complex hotspot statistics
- **Output**: Percentage of field area classified as extremes
### 3. **Enhanced Messaging Logic**
**Excellent Uniformity (CV ≤ 0.08, Acceptable ≥ 45%):**
- ✅ "Excellent field condition - optimal uniformity"
- 📊 "Continue current management practices"
**Good Uniformity with High Clustering (CV ≤ 0.15, Moran's I > 0.95):**
- 🔶 "Growth zones detected - potential for optimization"
- 📍 "Monitor clustered areas for development opportunities"
**Moderate Variation Issues:**
- 🔍 "Field shows moderate variation - investigate causes"
- 📈 "Consider zone-specific management approaches"
**Poor Uniformity (CV > 0.25 or Acceptable < 40%):**
- 🚨 "Urgent attention needed - poor field uniformity"
- ⚠️ "Immediate management intervention required"
## Key Thresholds
- **CI Change Thresholds:**
- Increase: ≥ +0.5
- Stable: -0.5 to +0.5
- Decrease: ≤ -0.5
- **Field Uniformity Thresholds:**
- Excellent: CV ≤ 0.08 AND Acceptable ≥ 45%
- Good: CV ≤ 0.15 AND Acceptable ≥ 45%
- Moderate: 0.15 < CV ≤ 0.25 OR 40% ≤ Acceptable < 45%
- Poor: CV > 0.25 OR Acceptable < 40%
- **Spatial Clustering Threshold:**
- Very High Clustering: Moran's I > 0.95
- Normal/Random: Moran's I ≤ 0.95
- **Extreme Values Threshold:**
- Extremes: Values outside mean ± 1.5 × standard deviation
- Acceptable area: Percentage of field within normal range
## Enhanced Alert Logic
**🚨🚨 URGENT ALERTS (High Priority):**
1. ✅ Poor field uniformity (CV > 0.25 or Acceptable < 40%)
2. ✅ Moderate variation with declining CI (zone-specific or field-wide)
**🔶 CLUSTERING NOTES:**
1. ✅ Good/excellent uniformity with very high clustering (Moran's I > 0.95)
2. ✅ Moderate variation with increasing CI and clustering
**🚨 STANDARD ALERTS:**
1. ✅ Moderate variation with stable CI (investigate practices)
**❌ NO ALERTS:**
1. ❌ Excellent uniformity with normal clustering
2. ❌ Good uniformity with normal clustering
## Actionable Insights
**For Excellent/Good Uniformity:**
- ✅ Continue current management practices
- 📊 Monitor for clustering patterns
- 🎯 Optimize growth zones if detected
**For Moderate Variation:**
- 🔍 Investigate specific zones or field-wide issues
- 📈 Consider zone-specific management
- 🌾 Review irrigation, fertilization, or pest management
**For Poor Uniformity:**
- 🚨 Immediate management intervention required
- 🎯 Focus on most problematic areas first
- 📊 Comprehensive field assessment needed