Title explains my predicament. I cannot open a tiff file using the raster package and receive an error that tells me it is due to a missing codec:


file_name <- "C:\\path\\to\\raster.tif"
r <- raster(file_name)


Error in .local(.Object, ...) : 
  C:\\path\\to\\raster.tif: Cannot open TIFF file due to missing codec.

Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",  : 
  Cannot create a RasterLayer object from this file.

Raster Compression Info:

Compression Type: ZSTD
Interleave: Band
Predictor Level: 3

Raster was created and compressed using gdal GTIFF driver and Creation Options API in Python

  • It seems that the reading GDAL is not built as required gdal.org/drivers/raster/gtiff.html#creation-options "ZSTD is available since GDAL 2.3 when using internal libtiff and if GDAL built against libzstd >=1.0, or if built against external libtiff with zstd support." If you can rewrite the TIFFs try DEFLATE or LZW compression.
    – user30184
    Apr 6, 2022 at 17:35
  • 1
    Converting the raster compression type to DEFLATE fixed the issue. Thank you! Apr 7, 2022 at 19:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.