I have two raster objects r1 (in grey and green) and r2 (in pink) that I want to intersect with R.I tried with the R function intersect from the raster package but it only intersect the extent of the two objects :
I would like to get a raster object r3 that have the shape of r2 (pink), but the values of r1.
Do you know how I can do this ?
EDIT :
I have a find a solution by firstly insersecting r1 and r2 into r3 then converting r3 and r2 to SpatialPolygonsDataFrame using the rasterToPolygonsfonction. The intersection of r3 and r2 converted into SpatialPolygonsDataFrame is close to what I wanted to get :
أكثر...

I would like to get a raster object r3 that have the shape of r2 (pink), but the values of r1.
Do you know how I can do this ?
EDIT :
I have a find a solution by firstly insersecting r1 and r2 into r3 then converting r3 and r2 to SpatialPolygonsDataFrame using the rasterToPolygonsfonction. The intersection of r3 and r2 converted into SpatialPolygonsDataFrame is close to what I wanted to get :

أكثر...