- forestatrisk.interpolate_rho(rho, input_raster, output_file='output/rho.tif', csize_orig=10, csize_new=1)[source]¶
Resample rho values with interpolation.
This function resamples the spatial random effects (rho values) obtained from an iCAR model. It performs a cubicspline interpolation at a finer resolution and smoothens the rho values.
- Parameters:
rho – Original rho values estimates with the iCAR model.
input_raster – Path to input raster defining the region.
output_file – Path to output raster file with resampled rho values.
csize_orig – Original size of the spatial cells (in km).
csize_new – New size of the spatial cells for cubicspline interpolation (in km).
- forestatrisk.wrast_rho(rho, input_raster, csize=10, output_file='output/rho_orig.tif')[source]¶
Write rho values to GeoTIFF.
This function writes rho values (spatial random effects) to a GeoTIFF raster file.
- Parameters:
rho – original rho values estimates with the iCAR model.
input_raster – path to input raster defining the region.
csize – size of the spatial cells (in km).
output_file – path to output raster file.
- forestatrisk.predict_raster(model, _x_design_info, var_dir='data', input_forest_raster='data/forest.tif', output_file='predictions.tif', blk_rows=128, verbose=True)[source]¶
Predict the spatial probability of deforestation from a statistical model.
This function predicts the spatial probability of deforestation from a statistical model. Computation are done by block and can be performed on large geographical areas.
- Parameters:
model – The model (glm, rf) to predict from. Must have a model.predict_proba() function.
_x_design_info – Design matrix information from patsy.
var_dir – Directory with rasters (.tif) of explicative variables.
input_forest_raster – Path to forest raster (1 for forest).
output_file – Name of the output raster file for predictions.
blk_rows – If > 0, number of rows for computation by block.
verbose – Logical. Whether to print messages or not. Default to
True
.
- forestatrisk.predict_raster_binomial_iCAR(model, var_dir='data', input_cell_raster='output/rho.tif', input_forest_raster='data/forest.tif', output_file='output/pred_binomial_iCAR.tif', blk_rows=128, verbose=True)[source]¶
Predict the spatial probability of deforestation from a model.
This function predicts the spatial probability of deforestation from a model_binomial_iCAR model. Computation are done by block and can be performed on large geographical areas.
- Parameters:
model – The model_binomial_iCAR model to predict from.
var_dir – Directory with rasters (.tif) of explicative variables.
input_cell_raster – Path to raster of rho values for spatial cells.
input_forest_raster – Path to forest raster (1 for forest).
output_file – Name of the raster file to output the probability map.
blk_rows – If > 0, number of rows for computation by block.
verbose – Logical. Whether to print messages or not. Default to
True
.
- forestatrisk.defrate_per_cat(fcc_file, riskmap_file, time_interval, period='calibration', tab_file_defrate='defrate_per_cat.csv', blk_rows=128, verbose=True)[source]¶
Compute deforestation rates per category of deforestation risk.
This function computes the historical deforestation rates for each category of spatial deforestation risk.
- Parameters:
fcc_file – Input raster file of forest cover change at three dates (123). 1: first period deforestation, 2: second period deforestation, 3: remaining forest at the end of the second period. No data value must be 0 (zero).
riskmap_file – Input raster file with categories of spatial deforestation risk.
time_interval – Time interval (in years) for forest cover change observations.
period – Either “calibration” (from t1 to t2), “validation” (from t2 to t3), “historical” or “forecast” (full historical period from t1 to t3). Default to “calibration”.
tab_file_defrate – Path to the
.csv
output file with estimates of deforestation rates per category of deforestation risk.blk_rows – If > 0, number of rows for computation by block.
verbose – Logical. Whether to print messages or not. Default to
True
.
- Returns:
None. A
.csv
file with deforestation rates per category of deforestation risk will be created (seetab_file_defrate
).