if (FALSE) { # interactive()
#For CRAN checks, a temporary directory is used to avoid leaving files.
#For permanent use, specify a path like "results/binary_raster.shp"
pre_fire <- get_external_data("NBRpre.tif", load = TRUE)
post_fire <- get_external_data("NBRpost.tif", load = TRUE)
shapefile_path <- file.path(tempdir(), "binary_raster.shp")
result <- binarize_raster(pre_fire, post_fire, shapefile_path = shapefile_path)
print(result$area_hectares)
# Clean up (optional)
unlink(list.files(tempdir(), pattern = "binary_raster\\.(shp|shx|dbf|prj)$", full.names = TRUE))
}
Run the code above in your browser using DataLab