floodfill¶
This is an implementation of the floodfill algorithm for fire event detection as described in:
Archibald, Sally & Roy, David. (2009).Identifying individual fires from satellite-derived burned area data.III-160 . 10.1109/IGARSS.2009.5417974.
Installation¶
To install this python package you need to download the repository,
navigate to the root folder of it and install it using the setup.py
:
python setup.py install
Usage¶
The program can be executed as a python module:
python -m floodfill -h
The program provides some command line parameters that let you define its behavior.
The -h
flag will give you an overview over the options and how to use it.
A simple test run can be done like this:
mkdir output
python -m floodfill --input=tests/test_data.tif --output-folder=output -b
Parallelization¶
If you have several files to process (in recursive mode), you can parallelize
processing by setting --n-workers
to a value that suits your number of cores
(if you specify a higher number of workers than you have cores, the program will
automatically take the maximum number of cores available).
mkdir output
python -m floodfill --input=tests/test_data.tif\
--output-folder=output\
--n-workers=4
Python API¶
User Interface¶
User interface for the module
- copyright
2020, Timo Nogueira Brockmeyer
- license
MIT
-
floodfill.
isolate_burned_pixels
(array, upper, lower)¶ This function sets alls entries of the given array with values between ‘upper’ and ‘lower’ to zero.
Usually the burned pixels have specific values (e.g. the julian day of the year) and other values may occur in the dataset. This function helps to ‘clean’ the data so that all values outside the bound of ‘upper’ and ‘lower’ are set to zero.
- Parameters
array (numpy.ndarray) – the raster data
upper (int) – the upper bound for the burned data values
lower (int) – the lower bound for the burned data values
- Returns
the cleaned raster data
- Return type
numpy.ndarray
-
floodfill.
read_data
(file)¶ Read the raster file and return a numpy array.
Only the first band of the raster file is read.
- Parameters
file (str) – file path
- Returns
a tuple of length two, containing an array of the raster data and the raster profile
- Return type
tuple
-
floodfill.
run_algo
(name, **kwargs)¶ Load an algorithm-module and run its run()-function.
- Parameters
name (str) – name of the module implementing the algorithm
- Returns
the return argument of therun function of the chosen algorithm implementation
-
floodfill.
write_data
(path, raster, profile)¶ Write the results to disc as a geotiff raster file.
- Parameters
path (str) – the file name and location to be written to
raster (numpy.ndarray) – the raster data
profile (rasterio.profiles.Profile) – the profile from the rasterio.io.DatasetReader
Algorithms¶
Floodfill algorithm as used in Nogueira et al.
- copyright
2020, Timo Nogueira Brockmeyer
- license
MIT
-
floodfill.algorithms.nogueira_etal.
run
(raster, cut_off)¶ The floodfill agorithm as described in the paper and implemented in Nogueira et al..
- Parameters
raster (numpy.ndarray) – the raster data
cut_off (int) – the cut-off value in days – this value is a temporal threshold of when to consider two fires distinct events.
- Returns
a tuple of length two, containing two numpy.ndarrays with the same dimensions as the input ‘raster’. The first item are the fire patches as connected components where each event has a unique id. The second item are the burn dates.
- Return type
tuple