Exporting Prescription Maps to John Deere GreenStar Format

Exporting prescription maps to John Deere GreenStar format requires generating a coordinate-aligned shapefile paired with a strictly structured Prescription.xml descriptor that maps geometry attributes to application rates, product IDs, and unit definitions. In Python, this is reliably achieved using geopandas for spatial vectorization and xml.etree.ElementTree to construct the GreenStar-compliant metadata file. The process bypasses proprietary desktop software by directly encoding the attribute schema that Gen 3/4 displays parse during field operations.

While many modern workflows default to Variable Rate Export to ISOXML for cross-platform compatibility, GreenStar’s native XML+Shapefile pipeline remains the most reliable for legacy displays and direct USB transfers. The following implementation handles projection normalization, attribute validation, and XML generation in a single reproducible script.

Prerequisites & Environment Setup

  • Python 3.9+ (required for xml.etree.ElementTree.indent)
  • geopandas ≥ 0.12
  • pandas ≥ 1.5
  • pyproj & fiona (automatically installed with geopandas)

Install dependencies via pip:

BASH
pip install geopandas pandas lxml

Complete Python Implementation

PYTHON
import geopandas as gpd
import pandas as pd
import xml.etree.ElementTree as ET
import warnings
from pathlib import Path

def export_greenstar_prescription(
    gdf: gpd.GeoDataFrame,
    output_dir: str,
    base_name: str = "Prescription",
    product_id: str = "1",
    product_name: str = "Nitrogen",
    rate_unit: str = "kg/ha",
    rate_column: str = "Rate"
) -> Path:
    """
    Exports a GeoDataFrame to John Deere GreenStar format (.shp + .xml).
    Returns the output directory path for verification.
    """
    out_path = Path(output_dir)
    out_path.mkdir(parents=True, exist_ok=True)

    # 1. Validate geometry
    if gdf.empty:
        raise ValueError("GeoDataFrame is empty. Cannot export prescription.")
    
    # 2. Normalize CRS to WGS84 (GreenStar Gen 3/4 expects EPSG:4326)
    if gdf.crs is None:
        warnings.warn("No CRS detected. Assuming EPSG:4326 (WGS84).")
        gdf = gdf.set_crs("EPSG:4326")
    elif gdf.crs.to_epsg() != 4326:
        gdf = gdf.to_crs("EPSG:4326")

    # 3. Validate & clean rate column
    if rate_column not in gdf.columns:
        raise KeyError(f"Rate column '{rate_column}' missing from GeoDataFrame.")
    
    gdf[rate_column] = pd.to_numeric(gdf[rate_column], errors="coerce").fillna(0.0)

    # 4. Export shapefile (uses Fiona/GDAL under the hood)
    shp_path = out_path / f"{base_name}.shp"
    gdf.to_file(shp_path, driver="ESRI Shapefile")

    # 5. Build GreenStar XML descriptor
    root = ET.Element("PrescriptionMap", version="1.0")
    
    # Product definition
    ET.SubElement(root, "Product", id=product_id, name=product_name, unit=rate_unit)
    
    # Rate table mapping
    rate_table = ET.SubElement(root, "RateTable", productId=product_id, sourceFile=f"{base_name}.shp")
    
    # Map each polygon/row to a rate entry
    for idx, row in gdf.iterrows():
        zone_id = str(row.get("ZoneID", idx))
        rate_val = f"{row[rate_column]:.2f}"
        ET.SubElement(rate_table, "RateEntry", zoneId=zone_id, rate=rate_val)

    # 6. Write XML with proper indentation
    ET.indent(root, space="  ", level=0)
    xml_path = out_path / "Prescription.xml"
    tree = ET.ElementTree(root)
    tree.write(xml_path, encoding="utf-8", xml_declaration=True)
    
    return out_path

Technical Breakdown

CRS Normalization

GreenStar displays natively consume WGS84 (EPSG:4326) for prescription geometry. Forcing this projection eliminates field-side coordinate drift and ensures the display aligns prescription zones with real-time GPS positioning. The script automatically detects missing or mismatched CRS definitions and applies a safe transformation.

Attribute Validation & Rate Cleaning

Prescription files fail silently if rate columns contain strings, NaN values, or non-numeric types. The implementation uses pd.to_numeric(..., errors="coerce") to sanitize inputs, replacing invalid entries with 0.0. This prevents XML parsing errors and guarantees the controller receives a continuous numeric stream.

XML Descriptor Construction

The Prescription.xml file acts as a manifest. It declares the product, links to the shapefile, and maps each geometry row to a specific application rate. The structure follows GreenStar’s documented schema for Gen 3/4 displays. Each <RateEntry> references a zoneId that matches the shapefile’s attribute table, enabling the controller to query rates by spatial intersection during operation.

Shapefile Export

The gdf.to_file() method leverages GDAL’s ESRI Shapefile driver. Ensure the output directory is writable and that no legacy .shp/.xml files with identical names exist, as shapefile exports will overwrite without warning. For advanced users, the GeoPandas to_file documentation details driver-specific parameters and schema overrides.

Deployment & Field Validation

  1. File Packaging: Copy Prescription.xml, Prescription.shp, Prescription.shx, Prescription.dbf, and Prescription.prj to a FAT32-formatted USB drive.
  2. Display Import: Insert the drive into the GreenStar 3/4 display. Navigate to Prescriptions > Import. The XML descriptor will auto-register the product and link geometry to the rate table.
  3. Field Verification: Before engaging the controller, run a dry pass in Simulate mode. Verify that:
  • Zone boundaries align with field boundaries
  • Rate transitions match agronomic intent
  • Unit conversions (e.g., kg/ha vs lbs/ac) match the implement configuration

If the display rejects the file, check for:

  • Non-WGS84 projections
  • Missing .prj or .dbf files
  • XML encoding mismatches (must be UTF-8)
  • Rate values exceeding implement capacity limits

Integration Context

This pipeline integrates cleanly into broader precision agriculture data stacks. When paired with satellite NDVI processing or soil grid sampling, the script becomes the final export step in a Yield Mapping & Variable Rate Prescription Generation workflow. For teams managing mixed-fleet equipment, consider maintaining dual export paths: GreenStar XML for John Deere hardware and ISOXML for AGCO/CNH implements. The underlying spatial logic remains identical; only the serialization layer changes.

Agricultural data standards continue to evolve under frameworks like ISO 11783-10 (Task Controller), which defines interoperable prescription structures across manufacturers. While ISOXML gains traction for cloud-synced operations, direct USB shapefile+XML transfers remain the industry standard for offline, high-reliability field execution.