0
votes

I'm working with two rasters that differ in their origin, extent, and resolution. I have a bathymetry raster, with a higher resolution (x=0.0008333333, y=0.0008333333) and a MUCH great spatial extent. I also have a sea surface temperature raster, which has a much coarser resolution (x=0.04166667, y=0.04166667). Both rasters have the same projection (longlat, datum=WGS84).

I would like to manipulate the bathymetry raster to match the extent, origin, and resolution of the sea surface temperature raster. However, I have very little experience and I am uncertain of the 'best practices.'

I have tried two different methods, and I would like to know which is better, and maybe an explanation of how they differ in terms of the underlying processes. I'm also open to other methods that might be better at preserving the data.

Method 1: 1) first, I aggregated the bathymetry raster to make it as similar to the SST raster as possible

library(raster)
bathycoarse<-aggregate(bathymetry, fact=c(48,50), fun=mean)

2) second, I cropped the bathymetry raster by the SST raster

bathycoarsecrop<-crop(bathycoarse,sst)

3) third, I resampled the bathymetry raster using the SST raster, resulting in the same origin and extent.

bathyresample<-resample(bathycoarsecrop, sst, method="bilinear")

Method 2: I used the function projectRaster()

bathy2<-projectRaster(bathymetry, sst, method="bilinear")

Obviously, method 2 is much simpler. But I don't really understand what the function is doing, so I want to make sure I am accomplishing my goal in the correct method.

1

1 Answers

1
votes

The "projectRaster" function uses the same resampling as the "resample" function (the resampling method is defined by the "method" argument you set to "bilinear" - indicating bilinear interpolation, which is probably what you want when your dealing with continuous numeric datasets). So using the function should just work fine for you.

If you want to speed things up, you can easily use paralell processing with the "projectRaster" function by starting a cluster with the "beginCluster" function, which then allows automatic parallel processing with the "projectRaster" function.

beginCluster(4) # use the number of cores you want to use
bathy2 <- projectRaster(bathymetry, sst, method="bilinear")
endCluster()