after several errors I finally managed to match my raster data but now I have a more or less general question. I`m still quite new and would like to understand what´s happening with my data. I have two sets of data->meteorological (MD) and reflactance (RF) they differ ins resolution and extent. First step was to match the resolution with disagg() this worked (but it´s a bit strange because when I checked them in ArcGIS pro and measure the pixels they are still 1000m, maybe someone know why. When proceding my calculations in R it seems fine and there is no error massage that resolution doesn´t match)
To match the extent I used ext(MD_crop)<-ext(RF_crop). I don´t understand what it is doing with my data When i use resample() it also works but there the values change and I don´t want that do happen. Can someone mybe explain the differences between these two "functions" a bit deeper? What would be the best practice in my case?
I didn´t really find a satisfying answer in the forum so far.
I tried to provide an example hopefully this works.
#create reproducable example
MD <- rast(nrows=71, ncols=49,vals=c(21.25958,63.43917))
crs(MD) <- "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs "
ext(MD)<-ext(c(610027.5, 659027.5, 5263464, 5334464))
res(MD)<-1000
RF <- rast(nrows=6944, ncols=3864,vals=c(0,9402))
crs(RF) <- "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs "
ext(RF)<-ext(c(612760, 651400, 5262480, 5331920))
res(RF)<-10
#disaggregate MD
MD_10<-disagg(MD, fact=c(100,100))
#crop rasters by extent
Ext<-ext(c(614630,649880,5266632,5321782))
MD_crop<-terra::crop(MD_10,Ext,snap="near", ext=TRUE)
RF_crop<-terra::crop(RF,Ext,snap="near", ext=TRUE)
> MD_crop
class : SpatRaster
dimensions : 5515, 3525, 1 (nrow, ncol, nlyr)
resolution : 10, 10 (x, y)
extent : 614627.5, 649877.5, 5266634, 5321784 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs
> RF_crop
class : SpatRaster
dimensions : 5515, 3525, 1 (nrow, ncol, nlyr)
resolution : 10, 10 (x, y)
extent : 614630, 649880, 5266630, 5321780 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs
#change witch extent-> this one is working but I don´t really understand
#what it is doing, does it change values? how does it get matching extents?
ext(MD_crop)<-ext(RF_crop)
class : SpatRaster
dimensions : 5515, 3525, 1 (nrow, ncol, nlyr)
resolution : 10, 10 (x, y)
extent : 614630, 649880, 5266630, 5321780 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs
#resample<-dimension and resolution fits but values change
MD_resample<-resample(MD_10,RF_crop)
class : SpatRaster
dimensions : 5516, 3525, 1 (nrow, ncol, nlyr)
resolution : 10, 10 (x, y)
extent : 614630, 649880, 5266630, 5321790 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs
> RF_crop
class : SpatRaster
dimensions : 5516, 3525, 1 (nrow, ncol, nlyr)
resolution : 10, 10 (x, y)
extent : 614630, 649880, 5266630, 5321790 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs