0

) I want to resample Sentinel-2 imagery so the resolution of two bands fit. I'm using raster::resample(raster1, raster2, method="ngb") for this, but the execution takes very very long. It is running for at least 15 minutes and so far I didn't obtain any output. I'm not sure if this will finish at some point.

I'm using bands 08 (10 m resolution) and 12 (20 m resolution) of Sentinel-2.

Resampling the same raster with QGIS takes a minute or so. I wanted to ask if this is a common problem with this function and if there is any workaround or another function/package I could use for that.

Thank you :-)

Denny
  • 47
  • 1
  • 4

2 Answers2

1

You could try the function gdalwarp from the package gdalUtils.

Here there is an example on how to use gdalwarp for resampling:

https://csaybar.github.io/blog/2018/12/05/resample/

Here there is an example of a resampling function based ongdalwarp:

https://rdrr.io/github/AybarCL/Dorado/src/R/resample_R.R

If you have GRASS GIS installed, you could also have a look at the fasterRaster package that has a fasterProjectRaster function.

Ehuber
  • 61
  • 4
  • Amazing! You are my hero! :-) gdalwarp worked very well and finished in 50 seconds. But it's strange that raster::resample does not work for me... I let it run for over an hour without finishing. However, I will use gdalwarp instead :-) – Denny Aug 18 '21 at 11:16
1

Maybe the terra package is faster, although I have not done a speed test for this task.

Same syntax and arguments:

resampled_raster <- terra::resample(raster1, raster2, method = "ngb")
Martin Gal
  • 16,640
  • 5
  • 21
  • 39
sermomon
  • 254
  • 1
  • 11