Multiplying two rasters having different cell sizes in R

  Kiến thức lập trình

I want to multiply Landsat 30m resolution image with an ERA5 raster of about 25km resolution. I can downscale ERA5 to 30m but it would increase processing. I am just wondering is it possible that whichever 30m cells overlap with 25km cell, these 30m cells get multiplied by single value from 25km cell.

library(terra)
### 1st raster
ETrF <- rast(ncols=4, nrows=4, xmin=73, xmax=75, ymin=31, ymax=33)
### 2nd raster
ET0 <- rast(ncols=2, nrows=2, xmin=73, xmax=75, ymin=31, ymax=33)
### Random values assigned to both rasters
values(ETrF) <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8)
values(ET0) <- c(5,1,2,4)

### Now 1st cell of ET0 (value: 5) will overlap with 1st,2nd,5th and 6th cells (values: 0.1,0.2,0.5,0.6) 
### of ETrF.Is it possible that 5 gets multiplied with 0.1,0.2,0.5 and 0.6 and final output 
### keeps ETrFs resolution.

ETa <- ETrF*ET0.....?

LEAVE A COMMENT