I have a Sentinel-1 image and Sentinel-2 images and I want to make the pixels in Sentinel-1 coincident to Sentinel-2. The more simple solution is put both images in the same geometry (spatial extent and resolution) using S2 <- resample(S2, S1)
, but I'm worry about the spectral information integrity. Is better resample the Sentinel-1 or Sentinel-2 and bilinear
is better for radar(S1) or nearest neighbor?
In my example:
# Packages
library(raster)
# Sentinel 1 and 2 samples
S1_sample <- stack("https://github.com/Leprechault/trash/raw/main/AguaSumida_PR001_1_2016-06-29_20160615_6_97EE.tif")
S1_sample
class : RasterStack
dimensions : 200, 200, 40000, 5 (nrow, ncol, ncell, nlayers)
resolution : 10, 10 (x, y)
extent : 445099.9, 447099.9, 7779496, 7781496 (xmin, xmax, ymin, ymax)
crs : +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs
names : vv, vh, RVI, RATIO, RFDI
min values : -22.5303173, -31.3865096, 1.7272604, 0.7599905, -0.6713753
max values : -2.9259523, -8.6576518, 3.3427506, 5.0859694, 0.1363698
S2_sample <-stack("https://github.com/Leprechault/trash/raw/main/AguaSumida_PR001_1_2019-08-06_20190801_T22KDC.tif")
S2_sample
class : RasterStack
dimensions : 201, 200, 40200, 4 (nrow, ncol, ncell, nlayers)
resolution : 10, 10 (x, y)
extent : 445100, 447100, 7779490, 7781500 (xmin, xmax, ymin, ymax)
crs : +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs
names : B2, B3, B4, B8
# Plotting
par(mfrow=c(1,2))
plotRGB(S1_sample, r = 3, g = 2, b = 1, stretch = "lin")
plotRGB(S2_sample, r = 3, g = 2, b = 1, stretch = "lin")
#
The final objective is extract the values of Sentinel-1 in the same pixels of Sentinel-2, including NAs (some times my images are crop in one of the sensors). Please, help me. Thanks in advance.
Example data
library(terra)
S1 <- rast("https://github.com/Leprechault/trash/raw/main/AguaSumida_PR001_1_2016-06-29_20160615_6_97EE.tif")
S2 <- rast("https://github.com/Leprechault/trash/raw/main/AguaSumida_PR001_1_2019-08-06_20190801_T22KDC.tif")
plot(S2, 1, legend=FALSE)
plot(S1, 1, add=TRUE, legend=FALSE, alpha=.5)
Your question is not very clear, but I think that you are looking for something like this:
S2 <- resample(S2, S1)
Now S1
and S2
have the same geometry (spatial extent and resolution).