I would like to disaggregate a list of raster files in R. I write the following code but receive an error.

# Import libraries

# Setup filelist and naming convention based off infiles
infiles <- list.files("infilepath here", full.names=TRUE)
names <- extension(basename(infiles), '.tif')

# Set output file naming convention
outpath <- "outfilepath here"
outfiles <- file.path(outpath, names)

# Loop function to disaggregate and write files
for (i in 1:length(infiles)) {
  r <- disaggregate(infiles[i], fact = 2, method='')
  writeRaster(r, paste(outfiles[i]), format ='GTiff', overwrite = T)

The error I receive is this:

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘disaggregate’ for signature ‘"character"’

1 Answer 1



infiles <- list.files("infilepath here", full.names=TRUE)
  r <- disaggregate(infiles[i], fact = 2, method='')

looks like you are trying to disaggregate the filename. Try disaggregate(raster(infiles[i]),[etc]) instead. This reads the file into a raster object to work with.


Your Answer

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

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