I used terra to implement the following process, read a large raster image, then read a smaller area of the vector file, and cropped, cropped the raster image to do some calculations.
library(terra)
ndvi <- rast(file.path(file_path,'ndvi.tif'))
vect <- vect(file.path(file_path,'plot.gpkg'))
ndvi_cropped <- crop(ndvi,vect,mask = TRUE)
ndvi_small <- 0.57*exp(2.33*ndvi_cropped)
I want to replace the value at the corresponding position in the big raster with the calculated value, regarding the replacement value I only found the cover function, but every time I run it directly, it will error.
cover(ndvi,ndvi_small)
#Error: [cover] raster dimensions do not match
You can do
m <- merge(ndvi_small, ndvi)