R/landmine-events.R
landmine_area_burned_by_zone.RdCounts burned pixels of currentBurn within each FRI zone and converts to hectares.
landmine_area_burned_by_zone(
currentBurn,
fireReturnInterval,
time,
pixelAreaHa
)A data.frame with columns time, nPixelsBurned, haBurned, FRI (a factor).
Fixes a bug. This previously counted burned pixels with
unname(table(currBurn[ids])[2]) – positional indexing into a table(), which assumes
the levels are always {0, 1} in that order. When a zone burns completely there is
only one level, so [2] is NA, and the following npix[is.na(npix)] <- 0 (whose comment
says it handles the no-burn case) silently converted it to its exact opposite: a
fully-burned zone was recorded as zero hectares burned. Counting with
sum(vals == 1, na.rm = TRUE) is correct in all three cases.