Fundamentals 8 min read

How to Implement a Forest Fire Spread Model in Java: Step‑by‑Step Guide

This article documents a Java implementation of a forest fire spread algorithm based on Wang Zhengfei's model, detailing the purpose, parameter definitions, and a series of computational methods—including wind and slope corrections, flame intensity, coordinate conversion, and spread speed—while noting the limitations of default parameter values.

Dunmao Tech Hub
Dunmao Tech Hub
Dunmao Tech Hub
How to Implement a Forest Fire Spread Model in Java: Step‑by‑Step Guide

Purpose

This document records a forest fire spread algorithm that can be used in fire‑prevention projects. It presents a basic implementation of the spread model, acknowledging that many parameters use default values and that results are only indicative unless richer sensor data are available.

Implementation Basis

The program follows the Wang Zhengfei forest fire spread model.

Parameter Description

x1

: longitude x2: latitude sj: wind direction offset (must be greater than n to invoke the spread algorithm) n: wind direction range index (0:225°, 1:270°, 2:315°, 3:0°, 4:45°, 5:90°, 6:135°, 7:180°) Winddir: wind direction angle Time: time s: mineral damping coefficient (default 0) v: ideal reaction speed (fast 50, medium 10, slow 1) speed: wind speed Wn: static fuel load (e.g., small trees 500 kg, medium 5 000 kg, large 500 000 kg) h: fuel heat value (e.g., wood 17) q: correction factor (default 1) density: density correction factor (default 1) a: correction factor (default 1) Qi: density (default 1) p: correction parameter (default 1) slope: slope

Code Methods

1. Calculate wind correction factor

private double CalWindCorr(double speed, double p) {
    double Qw;
    double B, C, E, b, c;
    c = 1.2;
    E = 0.715 * (Math.pow(Math.E, (-0.01094 * p)));
    C = 7.47 * (Math.pow(Math.E, (-0.8711 * Math.pow(p, 0.55))));
    B = 0.15988 * Math.pow(p, 0.54);
    b = 0.20395 * Math.pow(p, -0.8189);
    Qw = C * Math.pow(3.284 * speed, B) * Math.pow(c / b, -E);
    return Qw;
}

2. Calculate slope correction factor

public double CalSlopeCorr(double slope, double p) {
    double Qs;
    Qs = 5.275 * Math.pow(p, -0.3) * (Math.tan(slope * Math.PI / 180)) * (Math.tan(slope * Math.PI / 180));
    return Qs;
}

3. Calculate flame intensity

private double CalIr(double v, double Wn, double h, double m, double s) {
    double Ir;
    Ir = v * Wn * h * m * s;
    return Ir;
}

4. Calculate next coordinate

public XY GetNextFeature(double x, double y, double s, int n, int sj, double fengxiang) {
    double s1;
    int m;
    XY c1 = new XY();
    int number = 80;
    switch (n) {
        case 0:
            s1 = s * Math.sin((Math.PI) / 4);
            m = (int)(s1 / 80);
            // calculate coordinates for this wind direction
            break;
        // other wind directions omitted for brevity
    }
    return c1;
}

5. Calculate spread speed

public double SpreadSpeed(double n, double Winddir, double v, double Wn, double h, double m, double q, double density, double a, double Qi, double p, double slope, double speed, double s) {
    double angle = 0;
    double Ir;
    double R;
    double K = 1;
    if (n == 0) {
        angle = Math.abs(Winddir - 225);
        return K * (16 + 16 * (Math.cos(angle * Math.PI / 180)));
    }
    double speed_dy = CalWindCorr(speed, p);
    double slop_dy = CalSlopeCorr(slope, p);
    Ir = CalIr(v, Wn, h, m, s);
    R = (Ir * q * (1 + speed_dy + slop_dy)) / (density * a * Qi);
    return K * (R + R * Math.cos(angle * Math.PI / 180));
}

6. Longitude/latitude conversion

public XY lonLat2Mercator(double lon, double lat) {
    XY c1 = new XY();
    c1.setX(lon * 20037508.34 / 180);
    double Y2 = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
    c1.setY(Y2 * 20037508.34 / 180);
    return c1;
}

public XY Mercator2lonLat(double x, double y) {
    XY c1 = new XY();
    c1.setX(x / 20037508.34 * 180);
    double Y2 = y / 20037508.34 * 180;
    c1.setY(180 / Math.PI * (2 * Math.atan(Math.exp(Y2 * Math.PI / 180)) - Math.PI / 2));
    return c1;
}

7. Main method invocation

public XY HuygenSpread(double x1, double y1, int sj, int n, double Winddir, double Time, double s, double v, double speed, double Wn, double h, double q, double density, double a, double Qi, double p, double slope) {
    if (n < sj) {
        double huoyanspeed = SpreadSpeed(n, Winddir, v, Wn, h, n, q, density, a, Qi, p, slope, speed, s);
        System.err.println("huoyanspeed: " + huoyanspeed);
        double vtime = huoyanspeed * Time;
        System.err.println("vtime: " + vtime);
        XY c2 = lonLat2Mercator(x1, y1);
        XY c1 = GetNextFeature(c2.getX(), c2.getY(), 1.4 * vtime, n, sj, Winddir);
        c1 = Mercator2lonLat(c1.getX(), c1.getY());
        return c1;
    } else {
        XY c3 = new XY();
        c3.setX(x1);
        c3.setY(y1);
        return c3;
    }
}
Note: Because forest fire spread is influenced by many factors (e.g., static fuel load, mineral damping coefficient), the results provided are for reference only.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GeospatialEnvironmental ModelingForest Fire SimulationSpread Algorithm
Dunmao Tech Hub
Written by

Dunmao Tech Hub

Sharing selected technical articles synced from CSDN. Follow us on CSDN: Dunmao.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.