Picks a different start cell for each of a zone's fires, never on a pixel that cannot burn now, such as one burned earlier in the same year.

landmine_start_cells(pixel, n, available = rep(TRUE, length(pixel)))

Arguments

pixel

the candidate start cells of one FRI zone.

n

the number of fires the zone needs this round.

available

logical, as long as pixel; FALSE marks a pixel no fire may start on now. LandMine passes FALSE for the pixels earlier rounds of the year burned.

Value

n start cells, of the type of pixel, with NA for each fire left without one.

Details

The cells are drawn without replacement from pixel[available]. A zone with fewer available pixels than fires gives each available pixel a fire, and the remaining fires NA: they could only burn by starting on a pixel already burned that year, whose area would then be counted twice.

With every pixel available and n <= length(pixel), the draw is pixel[sample.int(length(pixel), n)], the same random numbers as SpaDES.tools:::resample(), which LandMine used before. A year whose fires all reach their targets in the first round is therefore unchanged.

Examples

set.seed(1)
landmine_start_cells(101:110, 3L, available = rep(c(TRUE, FALSE), 5))
#> [1] 101 107 105
landmine_start_cells(101:103, 5L, available = c(TRUE, FALSE, TRUE))
#> [1] 101 103  NA  NA  NA