Agriculture Template

Four-agent precision farming pipeline — multispectral imagery analysis, pest and disease detection, targeted spray recommendations, and yield forecasting.

Analyse drone or satellite imagery, detect crop stress and pests before they spread, and receive actionable treatment plans — all from a single workflow call.

Analyse drone or satellite imagery, detect crop stress and pests before they spread, and receive actionable treatment plans — all from a single workflow call.

python
from examples.cookbooks.Industry_Templates.agriculture_template import precision_agriculture_workflow

result = precision_agriculture_workflow("Field 12 multispectral scan — NDVI drop in north quadrant")
print(result)

The user uploads crop imagery; agents detect stress, pests, and irrigation recommendations per field.

Diagram

Precision Agriculture Workflow

🛸 Drone/Satellite

🤖 MultispectralAnalyzer

🤖 DiseaseIdentifier

🤖 SprayRecommender

🤖 YieldPredictor

✅ Farmer App

Quick Start

  1. Run the prebuilt workflow for multiple fields
    python
    from praisonaiagents import Agent, tool
    from examples.cookbooks.Industry_Templates.agriculture_template import precision_agriculture_workflow
    
    fields  = ["FIELD-001", "FIELD-002", "FIELD-003"]
    weather = {"temperature": 25, "humidity": 60, "wind_speed": 8, "precipitation": 0}
    
    result = precision_agriculture_workflow(fields, "wheat", weather)
    
    print(result["alerts"])
    print(result["yield_forecasts"])
    print(f"Sustainability score: {result['sustainability_score']:.0f}/100")
  2. Use IoT sensor network agent for real-time data
    python
    from examples.cookbooks.Industry_Templates.agriculture_template import IoTSensorPatterns
    
    sensor_agent = IoTSensorPatterns.create_sensor_network_agent(
        sensor_types=["soil_moisture", "temperature", "humidity", "ph"]
    )
    
    status = sensor_agent.start("Collect sensor readings from all FIELD-001 nodes")
    print(status)

How It Works

Diagram
“Farmer App”YieldPredictorSprayRecommenderDiseaseIdentifierMultispectralAnalyzer“Drone/Satellite”“Farmer App”YieldPredictorSprayRecommenderDiseaseIdentifierMultispectralAnalyzer“Drone/Satellite”Raw multispectral imageryMultispectralData schema (NDVI, NDRE, CCCI)PestDiseaseReport schemaSprayRecommendation schemaYieldForecast schema
AgentResponsibilitySLA
MultispectralAnalyzerCalculate NDVI/NDRE/CCCI vegetation indices and identify stress zones≤ 2 min per field
DiseaseIdentifierAI-based pest and disease classification with severity level≤ 30 s
SprayRecommenderTargeted spray strategy — product, rate, GPS zones, weather window≤ 1 min
YieldPredictorHarvest yield forecast with quality grade and market value estimate≤ 45 s

Configuration Options

Pydantic I/O schemas used by this template:

SchemaKey Fields
MultispectralDatafield_id, ndvi_index, ndre_index, ccci_index, moisture_level, temperature, affected_area, gps_coordinates
PestDiseaseReportreport_id, field_id, pest_type, disease_type, severity, affected_crops, spread_rate, confidence_score
SprayRecommendationrecommendation_id, field_id, treatment_type, product_name, application_rate, target_zones, optimal_time, cost_estimate, environmental_impact
YieldForecastforecast_id, field_id, crop_type, predicted_yield, confidence_interval, harvest_window, quality_grade, market_price_estimate

Severity levels (used in PestDiseaseReport)

LevelMeaningTypical action
noneNo threat detectedRoutine fertiliser application
lowEarly blight signsOrganic treatment (e.g. Neem Oil)
moderateLocalised infestationTargeted fungicide/pesticide
highSpreading infestationSystemic treatment + monitoring
severeField-wide outbreakEmergency intervention

Common Patterns

Integrated Pest Management (IPM) strategy by severity

python
from examples.cookbooks.Industry_Templates.agriculture_template import SustainableFarmingPatterns

strategy = SustainableFarmingPatterns.integrated_pest_management("moderate")
print(strategy)

Precision irrigation based on soil moisture

python
from examples.cookbooks.Industry_Templates.agriculture_template import SustainableFarmingPatterns

irrigation = SustainableFarmingPatterns.precision_irrigation(
    moisture_level=25.0,
    crop_stage="flowering"
)
print(f"Irrigate: {irrigation['irrigation_needed']}, Amount: {irrigation['amount_mm']} mm")

Recommend next crop for rotation

python
from examples.cookbooks.Industry_Templates.agriculture_template import SustainableFarmingPatterns

next_crop = SustainableFarmingPatterns.crop_rotation_optimizer("wheat", soil_data={})
print(f"Next crop: {next_crop}")

Best Practices

Fly imagery in optimal lighting conditions

MultispectralAnalyzer accuracy degrades significantly in overcast conditions or when shadows cover more than 20 % of a field. Schedule drone flights within 2 hours of solar noon for best NDVI readings.

Act on high-severity alerts within 24 hours

DiseaseIdentifier reports spread_rate in % per day. At high severity (spread_rate > 2 %), a one-day delay can double the affected area. The workflow automatically generates a SprayRecommendation for high/severe findings.

Monitor the sustainability_score trend

The workflow calculates a sustainability_score (0–100) based on total chemical application. Track this per season — a declining score signals overuse of pesticides, which correlates with long-term soil health degradation.

Validate GPS spray zones before field application

SprayRecommendation.target_zones contains GPS polygon boundaries. Always cross-check these against your field boundary GIS layer to prevent off-target application near water bodies or buffer zones.


Related