Skip to main content
added 1 character in body
Source Link
Jeffrey Evans
  • 32k
  • 2
  • 48
  • 97

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files
  ic <- srcsprc(lapply(img, rast))
    r <- mosaic(ic)

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files
  ic <- src(lapply(img, rast))
    r <- mosaic(ic)

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files
  ic <- sprc(lapply(img, rast))
    r <- mosaic(ic)
The object img was spelled sarimg in the lapply command
Source Link

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files
  ic <- src(lapply(sarimgimg, rast))
    r <- mosaic(ic)

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE)  
  ic <- src(lapply(sarimg, rast))
    r <- mosaic(ic)

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files
  ic <- src(lapply(img, rast))
    r <- mosaic(ic)
Source Link
Jeffrey Evans
  • 32k
  • 2
  • 48
  • 97

The terra package has a new object class SpatRasterCollection for image collections than can be used with terra::mosaic or terra::merge. This greatly simplifies mosaic operations. Here is an example where we: 1) create a vector of raster files; 2) use lapply to create raster objects wrapped in terra::src to create a SpatRasterCollection; 3) pass the image collection to the terra::mosaic function.

library(terra)
img <- list.files(getwd(), "tif$", full.names=TRUE)  
  ic <- src(lapply(sarimg, rast))
    r <- mosaic(ic)