- forestatrisk.plot.plot.correlation(y, data, output_file='correlation.pdf', plots_per_page=4, figsize=(8.27, 11.69), dpi=300)[source]¶
Correlation between variables and the probability of deforestation.
This function plots (i) the histogram of the explicative variables and (ii) the probability of deforestation by bins of equal number of observations for each explicative variable.
- Parameters:
y – A 1D array for the response variable (forest=1, defor=0).
data – A pandas DataFrame with column names.
output_file – Path to output file.
plots_per_page – Number of plots (lines) per page.
figsize – Figure size.
dpi – Resolution for output image.
- Returns:
List of Matplotlib figures.
- forestatrisk.plot.plot.differences(input_raster, output_file='differences.png', borders=None, zoom=None, figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot a map to compare outputs.
This function plots a map of differences between two rasters of predictions.
- Parameters:
input_raster – Path to raster of diffeences.
output_file – Name of the plot file.
borders – Vector file to be plotted.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the forest map.
- forestatrisk.plot.plot.fcc(input_fcc_raster, output_file='fcc.png', maxpixels=500000, borders=None, zoom=None, col_for=(34, 139, 34, 255), col_defor=(227, 26, 28, 255), figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot forest-cover change (fcc) map.
This function plots the forest-cover change map. Green is the remaining forest (value 1 in raster), the color specified is for deforestation (value 0 in raster).
- Parameters:
input_fcc_raster – Path to fcc raster.
output_file – Name of the plot file.
maxpixels – Maximum number of pixels to plot.
borders – Vector file to be plotted.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
col_for – rgba color for forest. Defaut to forest green.
col_defor – rgba color for deforestation. Default to red.
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the forest map.
- forestatrisk.plot.plot.fcc123(input_fcc_raster, output_file='fcc123.png', maxpixels=500000, borders=None, zoom=None, col=[(255, 165, 0, 255), (227, 26, 28, 255), (34, 139, 34, 255)], figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot forest-cover change (fcc123) map.
This function plots the forest-cover change map with 2 deforestation time-periods (2000 -> 2010 -> 2020 for example) plus the remaining forest (3 classes).
- Parameters:
input_fcc_raster – Path to fcc123 raster.
output_file – Name of the plot file.
maxpixels – Maximum number of pixels to plot.
borders – Vector file to be plotted.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
col – List of rgba colors for classes 123.
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the forest map.
- forestatrisk.plot.plot.fcc12345(input_fcc_raster, output_file='fcc12345.png', maxpixels=500000, borders=None, zoom=None, col=[(255, 165, 0, 255), (235, 100, 0, 255), (227, 26, 28, 255), (163, 26, 28, 255), (34, 139, 34, 255)], figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot forest-cover change (fcc12345) map.
This function plots the forest-cover change map with 4 deforestation time-periods (2000 -> 2005 -> 2010 -> 2015 -> 2020 for example) plus the remaining forest (5 classes).
- Parameters:
input_fcc_raster – Path to fcc12345 raster.
output_file – Name of the plot file.
maxpixels – Maximum number of pixels to plot.
borders – Vector file to be plotted.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
col – List of rgba colors for classes 12345.
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the forest map.
- forestatrisk.plot.plot.figure_as_image(fig, output_file)[source]¶
Remove borders and frames of a Matplotlib figure and save.
- Parameters:
fig – Matplotlib figure you want to save as the image.
output_file – Path to the output image file.
- Returns:
Figure without borders and frame.
- forestatrisk.plot.plot.forest(input_forest_raster, output_file='forest.png', maxpixels=500000, borders=None, zoom=None, figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot forest map.
This function plots the forest map in green. Raster values must be 0 (non-forest) and 1 (forest).
- Parameters:
input_forest_raster – Path to forest raster.
output_file – Name of the plot file.
maxpixels – Maximum number of pixels to plot.
borders – Vector file to be plotted.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the forest map.
- forestatrisk.plot.plot.freq_prob(stats, output_file='freq_prob.png', figsize=None, dpi=300)[source]¶
Plot distribution of probability values.
This function plots the distribution of the probability values.
- Parameters:
stats – Dictionary of statistics (counts, hectares, threshold, error, error_perc, ndp, nfp) returned by
.deforest()
.output_file – Name of the plot file.
figsize – Figure size in inches.
dpi – Resolution for output image.
- Returns:
A Matplotlib figure of the distribution of the probability values.
- forestatrisk.plot.plot.obs(sample, name_forest_var, input_fcc_raster, output_file='obs.png', zoom=None, s=20, figsize=(11.69, 8.27), dpi=300)[source]¶
Plot the sample points over the forest map.
This function plots the sample points over the forest map. Green is the remaining forest (value 1), red is the deforestation (value 0).
- Parameters:
sample – Pandas DataFrame with observation coordinates (X, Y).
name_forest_var – Name of the forest variable in sample DataFrame.
input_fcc_raster – Path to forest-cover change raster.
output_file – Name of the plot file.
zoom – Zoom to region (xmin, xmax, ymin, ymax).
s – Marker size for sample points.
figsize – Figure size in inches.
dpi – Resolution for output image.
- Returns:
A Matplotlib figure of the sample points.
- forestatrisk.plot.plot.plot_layer(filename, symbol, layer_index=0, **kwargs)[source]¶
Plots an OGR layer using the given symbol.
- forestatrisk.plot.plot.plot_line(line, symbol='k-', **kwargs)[source]¶
Plots a line using the given symbol.
- forestatrisk.plot.plot.plot_point(point, symbol='ko', **kwargs)[source]¶
Plots a point using the given symbol.
- forestatrisk.plot.plot.plot_polygon(poly, symbol='k-', **kwargs)[source]¶
Plots a polygon using the given symbol.
- forestatrisk.plot.plot.plot_polygon_fill(poly, symbol='w', **kwargs)[source]¶
Plots a polygon using the given symbol.
- forestatrisk.plot.plot.prob(input_prob_raster, output_file='prob.png', maxpixels=500000, borders=None, legend=False, figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot map of spatial probability of deforestation.
This function plots the spatial probability of deforestation.
- Parameters:
input_prob_raster – Path to raster of probabilities.
output_file – Name of the plot file.
maxpixels – Maximum number of pixels to plot.
borders – Vector file to be plotted.
legend – Add colorbar if True.
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the map of spatial probability of deforestation.
- forestatrisk.plot.plot.rho(input_rho_raster, output_file='rho.png', borders=None, figsize=(11.69, 8.27), dpi=300, **kwargs)[source]¶
Plot map of spatial random effects (rho).
This function plots the spatial random effects.
- Parameters:
input_rho_raster – Path to raster of random effects.
output_file – Name of the plot file.
borders – Vector file to be plotted.
figsize – Figure size in inches.
dpi – Resolution for output image.
**kwargs – see below.
- Keyword Arguments:
Additional arguments to plot borders.
- Returns:
A Matplotlib figure of the map of spatial random effects.
- forestatrisk.plot.plot.var(var_dir, output_file='var.pdf', gridsize=(3, 3), figsize=(11.69, 8.27), dpi=300)[source]¶
Plot variable maps.
This function plots variable maps.
- Parameters:
var_dir – Path to variable directory.
output_file – Name of the plot file.
grid_size – Grid size per page.
figsize – Figure size in inches.
dpi – Resolution for output image.
- Returns:
List of Matplotlib figures.