Skip to contents

This function checks if the provided tiff file is corrupted by attempting to describe it using the terra package and searching for the presence of a "Driver" string in the description, which indicates a valid tiff file. If the string is found, the function returns TRUE and FALSE otherwise.

Usage

CheckTiff(x = NULL)

Arguments

x

Character; the file path of the tiff file to be checked. The function will stop with an error if x is NULL or if the file does not exist.

Value

Logical; returns TRUE if the tiff file is not corrupted (i.e., it can be described and contains "Driver" in its description), and FALSE otherwise.

Note

This function depends on the terra, magrittr, and stringr packages.

Author

Ahmed El-Gabbas

Examples

(f <- system.file("ex/elev.tif", package="terra"))
#> [1] "/home/runner/work/_temp/Library/terra/ex/elev.tif"

CheckTiff(x = f)
#> [1] TRUE