I am running a batch conversion, .grd to .tif. This code worked fine with .rst to tif but now I get the error:

/ndmi.LC81270592013272.grd' not recognized as a supported file format.

This is my code:

                     outsuffix="_conv.tif",of="GTiff",pattern=".grd$", ot="Int16")
  • Which format .grd stands for? Some of there perhaps GSAG -raster- (rwv): Golden Software ASCII Grid (.grd) GSBG -raster- (rw+v): Golden Software Binary Grid (.grd) GS7BG -raster- (rw+v): Golden Software 7 Binary Grid (.grd) NWT_GRD -raster- (rw+v): Northwood Numeric Grid Format .grd/.tab Is your GDAL built with the driver, check with gdalinfo --formats. – user30184 Nov 8 '16 at 10:20

.grd is the header file for the native format of the raster package. As explained here, there is no gdal driver for that format, therefore you can't run gdal_translate on such files.

Two options to batch convert the files:

First option, create headers (does not duplicate the data)

Does not generate tiff files, but makes the files readable by most (all?) gis software.


files <- list.files('directory/with/files/to/convert', pattern = pattern = '^.*\\.grd$', full.names = TRUE)

makeHeader <- function(x){
    b <- brick(x)
    hdr(b, format = 'ENVI')

lapply(files, makeHeader)

Second option, read and write back to tiff (duplicates data)

files <- list.files('directory/with/files/to/convert', pattern = pattern = '^.*\\.grd$', full.names = TRUE)

convertToTiff <- function(x) {
    b <- brick(x)
    extension(x) <- '.tif'
    dt <- dataType(b)
    writeRaster(b, filename = x, datatype = dt)

lapply(files, convertToTiff)
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.