How to read raster data of multiple paths and rows using rast function?

I am trying to print and plot my Landsat data using rast function. I have Landsat data from 3 different paths/rows for one year. When I read my data using the rast function I get an error (Error: [rast] extents do not match). The images have the same projection.

library(terra)

lsat_path <- "D:/my_data/lsat_data/"

lsat_files <- list.files(lsat_path, full.names = TRUE)

lsat <- rast(lsat_files)

Could you please guide me to solve this problem?

Hi,

Could not check so I may be wrong, but following documentation rast(x) takes as arguments a filename (character), or spatRaster object or list of spatRaster objects. You supply a list of filenames, which seems incorrect.

Maybe try something like purrr(lsat_files, ~rast(.)), or 'apply' - family for base-R?

Hope it helps,
JW

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.