/
ff_analyze: Analyzing the results

ff_analyze: Analyzing the results

The ff_analyze function is designed to calculate performance metrics for deforestation predictions. It compares predictions against ground truth data, optionally using a forest mask, and can analyze results for specific geographic areas. The function can save results to a CSV file and return spatial polygons with calculated scores.

Exercises

  1. Basic Usage:
    Analyze predictions against ground truth data.

library(ForestForesight) library(terra) # Assume we have prediction and ground truth rasters predictions_raster <- rast("path/to/predictions.tif") groundtruth_raster <- rast("path/to/groundtruth.tif") analysis_results <- ff_analyze( predictions = predictions_raster, groundtruth = groundtruth_raster, verbose = TRUE ) print(head(analysis_results))
  1. Using a Forest Mask:
    Include a forest mask in the analysis to focus on forested areas.

forest_mask <- rast("path/to/forest_mask.tif") analysis_results <- ff_analyze( predictions = predictions_raster, groundtruth = groundtruth_raster, forestmask = forest_mask, verbose = TRUE ) print(summary(analysis_results))
  1. Saving Results to CSV:
    Analyze predictions and save results to a CSV file.

ff_analyze( predictions = "path/to/predictions.tif", groundtruth = "path/to/groundtruth.tif", csvfile = "deforestation_analysis_results.csv", append = FALSE, verbose = TRUE ) # Check if the CSV file was created file.exists("deforestation_analysis_results.csv")
  1. Analysis for a Specific Country:
    Perform analysis for a specific country using ISO3 code.

  1. Using Custom Analysis Polygons:
    Provide custom polygons for analysis instead of using default degree polygons.

  1. Analyzing Multiple Dates:
    Perform analysis for multiple dates and append results to a single CSV file.

These exercises will help you understand how to use the ff_analyze function to evaluate deforestation predictions, work with different data formats, and analyze results across various spatial and temporal contexts. Remember to replace the placeholder file paths with actual paths to your ForestForesight data and results.

Related content

ff_run: using the Forest Foresight package for training and predicting
ff_run: using the Forest Foresight package for training and predicting
More like this
Preprocessing your own datasets
Preprocessing your own datasets
More like this
ff_prep: data preparation
ff_prep: data preparation
More like this
ff_predict: Predicting deforestation
ff_predict: Predicting deforestation
More like this
ff_polygonize: creating actionable data from predictions
ff_polygonize: creating actionable data from predictions
More like this
Web Interface
Web Interface
More like this