I am using R and I have some issues to solve this problem: I have 2 rasters (same region, same resolution, same extent, same crs):
Raster A: (latitude, longitude, values_A)
class      : RasterLayer
dimensions : 832, 541, 450112  (nrow, ncol, ncell)
resolution : 0.008333333, 0.008333333  (x, y)
extent     : -122.2458, -117.7375, 35.0625, 41.99583  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
names      : values_A
values     : -753.4842, 0  (min, max)
Raster B: (latitude, longitude, elevation)
class      : RasterLayer
dimensions : 832, 541, 450112  (nrow, ncol, ncell)
resolution : 0.008333333, 0.008333333  (x, y)
extent     : -122.2458, -117.7375, 35.0625, 41.99583  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
names      : dem
values     : 40, 4176  (min, max)
I then need to obtain a plot of the raster A as a function of elevation and latitude (x= elevation, y= latitude, and as pixel values = values_A).
Moreover, I might have the need to aggregate pixels with the same latitude and the same elevation for example with a mean function.
do you have any suggestions on how to solve this problem with R?
Thank you!
 
     
    